soundje Posted August 3, 2009 Share Posted August 3, 2009 Hi Everybody, I am a very beginner in PHP, Please find my first script below: I created a html form and with this php script I would like to send it by mail: So far I have the code below: I also marked the "problem code" in bold and orange to make it more clear.. So the issue is that the value of $cursusid need to be looked up in a datbase and the return value of this query (kolumn cursus) needs to be send also with by email.. Please let me know if something is not clear and already a real THANK YOU for all your help Kindly regards Koen ----------------------------------------------------------------------- <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "[email protected]"; $email_subject = "XyZ - Inschrijvingsformulier Cursussen"; function died($error) { // your error code can go here echo "Gelieve terug te keren en de gegevens te vervolledigen of te wijzingen.<br /><br />"; echo $error."<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['naam']) || !isset($_POST['voornaam']) || !isset($_POST['adres']) || !isset($_POST['postcode']) || !isset($_POST['woonplaats']) || !isset($_POST['telefoon']) || !isset($_POST['Alg_voorwaarden']) || !isset($_POST['email'])) { died('Gelieve terug te keren en de gegevens te vervolledigen of te wijzingen.'); } $naam = $_POST['naam']; // not required $voornaam = $_POST['voornaam']; // not required $adres = $_POST['adres']; // not required $postcode = $_POST['postcode']; // not required $woonplaats = $_POST['woonplaats']; // not required $telefoon = $_POST['telefoon']; // not required $gsm = $_POST['gsm']; // not required $email_from = $_POST['email']; // required $geboorteplaats = $_POST['geboorteplaats']; // not required $geboortedatum = $_POST['geboortedatum']; // not required $opleiding = $_POST['opleiding']; // not required $andereopleiding = $_POST['andereopleiding']; // not required $beroep = $_POST['beroep']; // not required $opmerkingen = $_POST['opmerkingen']; // not required $Alg_voorwaarden = $_POST['Alg_voorwaarden']; // not required $bedrag_voorschot = $_POST['bedrag_voorschot']; // not required $overschrijving_datum = $_POST['overschrijving_datum']; // not required $overschrijving_naam = $_POST['overschrijving_naam']; // not required $cursusid = $_POST['cursusid']; // extra Koen $con = mysql_connect("localhost","xxx","xxx"); mysql_select_db("naturopathica_b", $con); $result = mysql_query("SELECT cursus FROM cursussen where ID=$cursusid")or die("dit Error: ".mysql_error()); $array = mysql_fetch_assoc($result); echo gettype($array['cursus']); mysql_close(); // $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'Ongeldig emailadres.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Inschrijving cursus .\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Naam: ".clean_string($naam)."\n"; $email_message .= "Voornaam: ".clean_string($voornaam)."\n"; $email_message .= "Adres: ".clean_string($adres)."\n"; $email_message .= "Postcode: ".clean_string($postcode)."\n"; $email_message .= "Woonplaats: ".clean_string($woonplaats)."\n"; $email_message .= "Telefoon: ".clean_string($telefoon)."\n"; $email_message .= "GSM: ".clean_string($gsm)."\n"; $email_message .= "E-mail: ".clean_string($email_from)."\n"; $email_message .= "Geboorteplaats: ".clean_string($geboorteplaats)."\n"; $email_message .= "Geboortedatum: ".clean_string($geboortedatum)."\n"; $email_message .= "Hoogst behaalde opleiding: ".clean_string($opleiding)."\n"; $email_message .= "Naschoolse opleiding: ".clean_string($andereopleiding)."\n"; $email_message .= "Beroep: ".clean_string($beroep)."\n"; $email_message .= "Opmerkingen: ".clean_string($opmerkingen)."\n"; $email_message .= "Aanvaarden van Algeme voorwaarden: ".clean_string($Alg_voorwaarden)."\n"; $email_message .= "Bedrag in voorschot: ".clean_string($bedrag_voorschot)."\n"; $email_message .= "Datum van overschrijving: ".clean_string($overschrijving_datum)."\n"; $email_message .= "Naam van rekeninghouder: ".clean_string($overschrijving_naam)."\n\n\n\n"; $email_message .= "CursusID : ".clean_string($cursusid)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <p>Wij danken u voor uw inschrijving op één van onze cursussen van Naturopathica. <? } ?> <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "http://www.naturopathica.be/" } //--> </script> </head> <body onLoad="setTimeout('delayer()', 5000)"> <p>Deze pagina zal automatische terug keren naar de website van Naturopathica over 5 seconden!</p> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/168633-beginner-help-needed-select-from/ Share on other sites More sharing options...
Adam Posted August 3, 2009 Share Posted August 3, 2009 What problems does the problem code give? Are you seeing the MySQL error? A PHP error? If not, what output are you seeing? Link to comment https://forums.phpfreaks.com/topic/168633-beginner-help-needed-select-from/#findComment-889584 Share on other sites More sharing options...
soundje Posted August 3, 2009 Author Share Posted August 3, 2009 Hi Adam, The output that I get from Mysql is "string"; I have tested the query with Phpadmin and there i got a the right output... regards Koen Link to comment https://forums.phpfreaks.com/topic/168633-beginner-help-needed-select-from/#findComment-889590 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.