Jump to content

Help with email form


cs1h

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.