Old 22-06-2007, 07:54   #1 (permalink)
jameszxcv
Registered User
 
jameszxcv's Avatar
 
Join Date: Nov 2006
Posts: 89
form direct

i am using a simple php form i found , and wondering if any ones how to simply when the send button is pressed and the email is sent the user of the website it directed back to the home page.

*form*

<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = 'YourAddr@YourMail.com';
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];

/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>




cheers
  Reply With Quote
Old 22-06-2007, 07:58   #2 (permalink)
d3mcfadden
Senior Member
 
d3mcfadden's Avatar
 
Join Date: Apr 2005
Location: -
Posts: 694
Send a message via AIM to d3mcfadden
php.net/header
  Reply With Quote
Old 22-06-2007, 08:15   #3 (permalink)
jameszxcv
Registered User
 
jameszxcv's Avatar
 
Join Date: Nov 2006
Posts: 89
thanks but i should add im very new to php so dont really know how/where to use this
  Reply With Quote
Old 22-06-2007, 08:24   #4 (permalink)
d3mcfadden
Senior Member
 
d3mcfadden's Avatar
 
Join Date: Apr 2005
Location: -
Posts: 694
Send a message via AIM to d3mcfadden
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$email = 'YourAddr@YourMail.com';
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];

/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
header("Location: yourpage.html");
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
<html>
<head><title>PHP Mail Sender</title></head>
<body>

</body>
</html>


easiest way to do it in that jumbled mess.
  Reply With Quote
Old 22-06-2007, 09:57   #5 (permalink)
jameszxcv
Registered User
 
jameszxcv's Avatar
 
Join Date: Nov 2006
Posts: 89
cheers mate worked great
  Reply With Quote
Old 03-07-2007, 17:39   #6 (permalink)
jameszxcv
Registered User
 
jameszxcv's Avatar
 
Join Date: Nov 2006
Posts: 89
i need help with this again , sorry

does any one know how to fix this problem. when some one uses the contact form and sends it. when i look at the email it does not say its from the person how sent it but from root@dubli.purplecloud.com.

does any one know how to fix this so it says the person how accully sent it?

thanks for any help
  Reply With Quote
Old 03-07-2007, 18:17   #7 (permalink)
d3mcfadden
Senior Member
 
d3mcfadden's Avatar
 
Join Date: Apr 2005
Location: -
Posts: 694
Send a message via AIM to d3mcfadden
php.net/mail research the headers parameter
  Reply With Quote
Old 03-07-2007, 18:20   #8 (permalink)
Paul
Junkie[scum]
 
Paul's Avatar
 
Join Date: Oct 2006
Location: location, location
Posts: 1,813
Form Validation With PHP

decent script which can show you your errors ... ignore the fuckin use of tables
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8