November 13, 200917 yr Hi! Haven't been here in a while. I have a problem, I'm trying to make a simple php form but it just wont work. Here is the code i would like to use. Could you please explain me where I have to put it? <table width="400" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td><strong>Contact Form </strong></td> </tr> </table> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1"> <tr> <td><form name="form1" method="post" action="send_contact.php"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <td width="16%">Subject</td> <td width="2%">:</td> <td width="82%"><input name="subject" type="text" id="subject" size="50"></td> </tr> <tr> <td>Detail</td> <td>:</td> <td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td> </tr> <tr> <td>Name</td> <td>:</td> <td><input name="name" type="text" id="name" size="50"></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input name="customer_mail" type="text" id="customer_mail" size="50"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </form> </td> </tr> </table> <?php // Contact subject $subject ="$subject"; // Details $message="$detail"; // Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='someone@somewhere.com'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?>
November 13, 200917 yr The table code goes into your main page but it must have an extension .php (not .html) The second code above goes into a page called send_contact.php in the same folder/directory as the main page. However, you need some more variables and $subject= "$subject" is wrong, it just repeats itself and $message = "$detail" is wrong. <?php // Contact subject $subject =$_POST['subject'] ; // Details $message=$_POST['detail']; $name =$_POST['name']; $customer_mail = $_POST['customer_mail']; // Mail of sender $mail_from="$customer_mail"; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='someone@somewhere.com'; $send_contact=mail($to,$subject,$message,$header); mail($to,$subject,$message,$header); //this may be unnecessary or it may send the email a second time because of the variable above, I'm not sure. // Check, if message sent to your email // display message "We've received your information" if($send_contact){ echo "We've received your contact information"; } else { echo "ERROR"; } ?> I haven't tested the above edits; more may be required.
November 13, 200917 yr Author Wickham Hey thanks for fast reply! Ok, now i start to understand it a bit, so I have to save my contact.html as contact.php? How about the script? Just make new php page and paste the correct script and name it send_contact.php... What do you mean by main page...index.html?
November 13, 200917 yr Ok, now i start to understand it a bit, so I have to save my contact.html as contact.php? How about the script? Just make new php page and paste the correct script and name it send_contact.php... What do you mean by main page...index.html? save my contact.html as contact.php - Yes or the PHP won't work. Just make new php page and paste the correct script and name it send_contact.php - Yes, just the script from <?php to ?> What do you mean by main page...index.html - I mean contact.php I'm fairly sure the edits I've made are OK but there may be more required; I haven't tested and my PHP isn't perfect.
November 13, 200917 yr Author Wickham Ok all clear :] I'll look for another script on the net. Thanks a lot!
November 16, 200917 yr Author Hey! One more question... When i save "contact.html" to "contact.php" it just turns in to dream weaver php file(i'm using dream weaver). I'm not sure if that's suppose to happen?:s
Create an account or sign in to comment