Jump to content

Contact form problems


JeanieTallis

Recommended Posts

It's a basic contact form.

 

<?php 
if (isset($_POST['submit'])) { // if form has been submitted
    /* check they filled in what they supposed to etc: full name, email and comments */

    if (!$_POST['full_name'] || !$_POST['email'] ||
        !$_POST['comments'])
        {
        die('You did not fill in a required field.');	
	}	

		    if (!get_magic_quotes_gpc()) {
        $_POST['full_name'] = addslashes($_POST['full_name']);
    }

	    if (!preg_match("/.*@.*..*/", $_POST['email']) ||
         preg_match("/(<|>)/", $_POST['email'])) {
        die('Invalid e-mail address.');
    }

	$_POST['full_name'] = strip_tags($_POST['full_name']);
    $_POST['comments'] = strip_tags($_POST['comments']);

	    if (!get_magic_quotes_gpc()) {
	$_POST['full_name'] = addslashes($_POST['full_name']);
        $_POST['email'] = addslashes($_POST['email']);
        $_POST['comments'] = addslashes($_POST['comments']);
    }	

$message = 
"Comments from Contact form\n\n
Name: $_POST[full_name] \n
Email: $_POST[email] \n
Comments: $_POST[comments] \n
";
        /* Mail To, subject, message */ 
$my_email = "admin@jeanies-poetry.com", "Contact Form Reply", $message,
    "From:" \$_POST[full_name]\ $_POST[email]. /* Mail From */
     "X-Mailer: PHP/" . phpversion());
echo("Your email has been sent, you will get a reply shortly.");	

exit;	
}
?> 

<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <label>
  <div align="center">Full Name:
    <input name="full_name" type="text" id="full_name">
  </div>
  </label>
  <p align="center">
    <label>Your Email:
    <input name="email" type="text" id="email">
    </label>
  </p>
  <p align="center">
    <label>Comments<br>
    <textarea name="comments" cols="80" rows="20" id="comments"></textarea>
    </label>
  </p>
  <p align="center">
    <label>
    <input name="submit" type="submit" id="submit" value="Send">
    </label>
  </p>
</form>

 

The mail to and from, are wrong. Can you correct this. Thanks

Link to comment
Share on other sites

What's wrong and what happens?

 

Well, everythings correct, its just this bit is that we focus at (origionally what i had is below)

	mail($_POST['email'] , "Contact Form Reply", $message,
    "From: \"Auto-Response\" <admin@jeanies-poetry.com>\r\n".
     "X-Mailer: PHP/" . phpversion());
echo("Your email has been sent, you will get a reply shortly.");	

 

This emails the person using the contact form, coming from the person I want it to go to.

admin@jeanies-poetry.com is who I want the form to go to.

$_POST['email'] is, the email the person on the contact form enters in (there email) and thats who the email comes from.

 

I want to know, how to change that bit to make the form go to admin@jeanies-poetry.com from there email address they enter.

Link to comment
Share on other sites

The first parameter for MAIL () is the TO field

 

mail ("admin@jeanies-poetry.com","Contact Form Reply", $message, "FROM: \"Auto-Response\" <admin@jeanies-poetry.com>\r\n X-Mailer: PHP/" . phpversion());

 

But many webhosts won't let you use a FROM address that is not part of your domain.

Link to comment
Share on other sites

The first parameter for MAIL () is the TO field

 

mail ("admin@jeanies-poetry.com","Contact Form Reply", $message, "FROM: \"Auto-Response\" <admin@jeanies-poetry.com>\r\n X-Mailer: PHP/" . phpversion());

 

But many webhosts won't let you use a FROM address that is not part of your domain.

 

Thank you for the help

can you check out the last post on my other thread

http://www.phpfreaks.com/forums/index.php?topic=243205

its a download for my .rar login form, i have alot of errors within it.

 

Thanks.

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.