cs1h Posted September 27, 2007 Author Share Posted September 27, 2007 Hi, Thanks for the help, that seems to be working now. The form is ment to send the email to the email address got from the first text box and the id is needed to be able to make a link to link people back to the site. However even though it now seems that no errors are coming up it is also not sending the email or saying that it has been sent. Do you think that I have gone about this all wrong? Any thoughts are much appriciated. Cheers, Colin Quote Link to comment https://forums.phpfreaks.com/topic/70945-help-with-email-form/page/2/#findComment-356840 Share on other sites More sharing options...
MadTechie Posted September 27, 2007 Share Posted September 27, 2007 try this, i assume that the first form is passing id via GET <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form name="frmsendmail" method="post" action="emailform.php" onSubmit="return ValidationForm()"> <table border="0"> <tr> <td>Send to:</td> <td><input type="text" name="Email" id="Email" /></td> </tr> <tr> <td>From:</td> <td><input type="text" name="From" id="From" /></td> </tr> <tr> <td>Send:</td> <td><input type="submit" name="Send" id="Send" value="Submit" /></td> </tr> </table> <input type="hidden" name="id" value="<?php echo $_GET['id'];?>" /> </form> <?php if( isset($_POST['submit']) ) { $conn=mysql_connect("localhost","adder","clifford"); mysql_select_db("real",$conn) or die("Unable to select database"); if( !isset($_POST['id']) ) exit("Nothing Selected"); // error capture $art = (int)$_POST['id']; //clean $sql = "SELECT * FROM items WHERE id=$art"; $result = mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows == 0) { echo "There has been a problem with your request please try again."; } else { while($row = mysql_fetch_assoc($result)) { $Title = $row['Title']; //Check whether the submission is made if(isset($hidSubmit)) { //Declarate the necessary variables $mail_to=$Email; $mail_from=$From; $mail_sub="Please read this"; $mail_mesg= "You have been recomended to read the article $Title on www.myroho.com click <a href=www.myroho.com/more.php?id=$art>here</a> to read it."; //Check for success/failure of delivery if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from")) { echo "<span class='textred'>E-mail has been sent successfully you can now send another email or close the window</span>"; }else{ echo "<span class='textred'>Failed to send the E-mail from $mail_sub to $mail_to</span>"; } } } } } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/70945-help-with-email-form/page/2/#findComment-356854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.