hulp gezocht ibj het maken van contact pagina

Status
Niet open voor verdere reacties.

ciske de rat

Verenigingslid
Lid geworden
10 jun 2003
Berichten
964
ik zit al een tijd je met de vraag hoe en wat maar
kom er niet uit
ik wil graag aan mijn website een contact pagina aanmaken
maar nu stuit ik er op dat de mail telkens niet verzonden wordt of hij opent outlook

ik er iemand die mijn aan een passend script kan helpen met uit leg hoe en wat te kopelen aan data base enz zodat mensen niet hun eigen outlook in hoeven
dat alles rechtstreeks via de site gaat
de website is gehost bij http://dhost.info/
 
Moet het perse via je database?

Ik heb ooit een simpel contact form moduletje geschreven dat je kunt gebruiken anders; staat hier:
http://helpmij.nl/forum/showthread.php?t=396520

Het stuurt gewoon een mailtje volgens een door jou gemaakt template naar de opgegeven adressen.
 
toch nog een vraag

ik zit naar script te kijken en ik zou niet weten waar ik wat moet invullen om gebriuk te kunnen maken van dit script
contact.php
<?php
/**
* @author: Erik Roelofs
* @created: 4 jan 2009
* @email: erik@ruigekonijnen.nl
* @desc: This simple script allows users to make simple contact forms, using a .txt template file.
*/

// make sure data is sent in.
if ( $_SERVER['REQUEST_METHOD'] !== 'POST' || !isset ( $_POST['template'] ) ) {
redirect();
}

// make sure the template input is directory safe; no back-skipping.
if ( strpos ( $_POST['template'], '..' ) !== false ) {
// contains a reference to '..', trying to change directories. this is NOT allowed.
redirect();
}

// make sure this template exists
if ( !file_exists ( $_POST['template'] . '.txt' ) ) {
// this appears to be a bad template?
redirect();
}

// recover the template we're going to use
$aTemplate = file ( $_POST['template'] . '.txt' );

// determine the length of the template
$iLengthOfTemplate = count ( $aTemplate );
// at the beginning, we have not yet reached the template itself.
$bTemplate = false;
// these will be the receivers of the mail
$aReceivers = array();
// this is the mail subject
$sSubject = 'Default subject';
// this is the mail template to use.
$sTemplate = 'Default template';
// this is where we send the user after he filled in the contact form
$sGoto = '';

// run over the file to collect the neccesary information
for ( $i = 0 ; $i < $iLengthOfTemplate ; $i++ ) {
$sLineValue = $aTemplate[ $i ];
if ( strpos ( $sLineValue, '>>RECEIVERS>>' ) !== false ) {
// this is the line that shows we are in the receivers section; skip it over.
unset ( $aTemplate[ $i ] );
continue;
}
if ( strpos ( $sLineValue, '>>SUBJECT>>' ) !== false ) {
// we reached the subject.
$sSubject = $aTemplate[ $i + 1 ];
unset ( $aTemplate[ $i ] );
unset ( $aTemplate[ $i + 1 ] );
// move to the next entry; since we need to skip over it
$i++;
$bTemplate = true;
continue;
}
if ( strpos ( $sLineValue, '>>MESSAGE>>' ) !== false ) {
// the message starts here
unset ( $aTemplate[ $i ] );
// we have a real template; so drop the dummy
$sTemplate = '';
$bTemplate = true;
continue;
}
if ( strpos ( $sLineValue, '>>GOTO>>' ) !== false ) {
// this is where we go on a success
$sGoto = $aTemplate[ $i + 1 ];
unset ( $aTemplate[ $i ] );
unset ( $aTemplate[ $i + 1 ] );
// move to the next entry; since we need to skip over it
$i++;
continue;
}
if ( $bTemplate ) {
// this is part of the template
$sTemplate .= $sLineValue;
}
else {
// this is one of the receivers
// strip out whitespace, return, newlines, and spaces.
$sAddress = str_replace ( array ( "\n", "\r", "\t", " " ), '', $sLineValue );
$aReceivers[] = $sAddress;
}
}

// no receivers, means nothing to do? whatever; success!
if ( count ( $aReceivers ) == 0 ) {
success( $sGoto );
}

// get all the keys and values from the form sent in
foreach ( $_POST as $sKey => $sValue ) {
$aSearch[] = '##' . $sKey . '##';
$aReplace[] = $sValue;
}

// replace the markers in the template file with their values
$sTemplate = str_replace ( $aSearch, $aReplace, $sTemplate );

// send the mail to each of these people
foreach ( $aReceivers as $sReceiver ) {
mail ( $sReceiver, $sSubject, $sTemplate );
}

// and we're done.
success( $sGoto );

/**
* Two functions; one to redirect to the main host for bad requests and one to send the user back to the previous page it the mail was sent properly
*/
function redirect () {
header ( 'Location: http://' . $_SERVER["HTTP_HOST"] . '/' );
exit;
}

function success ( $sGoto ) {
if ( empty ( $sGoto ) ) {
if ( isset ( $_SERVER["HTTP_REFERER"] ) ) {
// determine whether a query string was already present
if ( strpos ( $_SERVER["HTTP_REFERER"], '?' ) !== false ) {
// it was
$sSendTo = $_SERVER["HTTP_REFERER"] . '&sent=true';
}
else {
// it wasn't
$sSendTo = $_SERVER["HTTP_REFERER"] . '?sent=true';
}
}
else {
// no referer? send back to index, then.
$sSendTo = 'http://' . $_SERVER["HTTP_HOST"] . '/?sent=true';
}
}
else {
// the user set a Goto for after the form. go there now.
$sSendTo = $sGoto;
}

header ( 'Location: ' . $sSendTo );
exit;
}

?>

exampleform.html
<html>
<head>
</head>
<body>
<h1>This is a very basic form.</h1>
<form action="contact.php" method="post" >
<!-- this hidden input references the file 'exampletemplate.txt' in the main directory of the webfolder -->
<input type="hidden" name="template" value="exampletemplate" /><br />
<table>
<tr>
<!-- these fields are all used in the Template, and they will be sent to you -->
<td><label for="name">Your name:</label></td>
<td><input type="text" name="name" value="Erik" /></td>
</tr>
<tr>
<!-- these fields are all used in the Template, and they will be sent to you -->
<td><label for="name">Your email:</label></td>
<td><input type="text" name="email" value="my-email@example.com" /></td>
</tr>
<tr>
<!-- these fields are all used in the Template, and they will be sent to you -->
<td><label for="name">Your message:</label></td>
<td><input type="text" name="message" value="Hai!" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="send!" /></td>
</tr>
</table>
</form>
</body>
</html>
<!--
the template will send a mail looking something like this: (if the user didn't change any of the fields)

This is an example template.

Erik wants to contact you.
He would like a reply to go to: my-email@example.com

His message was:
Hai!
 
Lees de instructies die er bij zitten ;)

Dat .php script moet je niet aan zitten; dat zet je gewoon ergens neer en dan kun je je FORM er naar toe wijzen.

Kijk maar naar het example; je zet een FORM action="script.php" en vervolgens maak je een simpele template.txt ergens aan die je wilt hebben bij het versturen.
In je Form zet je een hidden veld, met de naam template en als value het bestand dat je wilt gebruiken;

<input type="hidden" name="template" value="templatenaam" /><br />

Dan maak je een bestand aan dat templatenaam.txt heet, en die bouw je volgens de instructies (ook dat kun je afkijken op het voorbeeld)
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan