PDA

View Full Version : Whats up with this? [PHP]



Jamieb
01-02-2009, 11:33 PM
Hey why does this not send ? Im suck:( +rep any help thanks Jamieb.


<?php
// Change these two variables to meet your needs.
$myemail = '[email protected]';
$subject = 'jobs';
$op = $_POST[op];
if($op == 'contact')
{
$name = stripslashes($_POST[name]);
$age = stripslashes($_POST[age]);
$email = stripslashes($_POST[email]);
$job = stripslashes($_POST[job]);
$contents = stripslashes($_POST[contents]);
$referer = $_POST[referer];
$remote_host = $_SERVER[REMOTE_ADDR];
$server = $_SERVER[SERVER_NAME];
$browser = $_SERVER[HTTP_USER_AGENT];
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email))
{
$status = "We're sorry, but you've entered an incorrect email address.<br>";
}
if(!$name)
{
$status .= "Please enter your name.<br>";
}
if(!$text)
{
$status .= "Please enter a message.<br>";
}
if(!$status)
{
$header = "From: $email\r\nReply-To: $email\r\n";
$message = "
Name: $name
Name: $age
Name: $email
Name: $job
Name: $age
Name: $contents
Referer: $text
Site: $server
Remote Host: $remote_host
Remote Browser: $browser
$text
";
if(mail($myemail, $subject, $message, $header))
{
$status = "Thank you for your Feedback!!<br><br>";
}
else
{
$status = "There was a problem sending your feedback, please try again later.<br><br>";
}
}
else
{
$status .= "<br>Please press <u>back</u> on your browser to resubmit.<br><br>";
}
}
// Now check the referer page and ensure it's a proper URL
$referer = $_SERVER[HTTP_REFERER];
if(!preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $referer))
{
unset($referer);
}
?>
<?php print $status; ?>
<form method="post" action="<?php print $_SELF; ?>">
<input type="hidden" name="op" value="contact">
<input type="hidden" name="referer" value="<?php print $referer; ?>">
<font face="Verdana" size="1">Full&nbsp; Name<br>
<input name="name" size="35" value=""><br>
Age<br><input name="age" size="35" value=""><br>
E-mail address<br><input name="email" size="35" value=""><br>
Job('s) applying for<br><input name="job" size="35" value=""><br>
<br>Why should you get it? Past experance.<br><textarea name="contents" cols="30" rows="10"></textarea><br><br>
<input type="submit" value="Send"></font>

Ryzie
02-02-2009, 07:47 AM
Is the PHP Mail function enabled by your host?

Jamieb
02-02-2009, 04:15 PM
yeh i had it working but then i added fields to it and it broke.

Joe!
02-02-2009, 06:17 PM
Put like $_POST['op'] notice the 's, i think that will solve your issue, if you actually put the marks in, obiously for all your $_POST variables. :)

Moh
02-02-2009, 07:24 PM
There's a few problems there.

Try this code, it will do what you want it to do =D



<!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>Job Application</title>
<style type="text/css">
body {
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
}
p,input,textarea {
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
}
</style>
</head>
<body>
<?php
if (isset ( $_POST ["name"] ) && isset ( $_POST ["age"] ) && isset ( $_POST ["email"] ) && isset ( $_POST ["job"] ) && isset ( $_POST ["message"] )) {
$name = stripslashes ( $_POST ["name"] );
$age = stripslashes ( $_POST ["age"] );
$email = stripslashes ( $_POST ["email"] );
$job = stripslashes ( $_POST ["job"] );
$message = stripslashes ( $_POST ["message"] );
$ip = $_SERVER ["REMOTE_ADDR"];
$server = $_SERVER ["SERVER_NAME"];
$browser = $_SERVER ["HTTP_USER_AGENT"];
$referer = $_SERVER ["HTTP_REFERER"];

if (! preg_match ( '#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $referer )) {
$referer = "No Referer";
}
if ($name == "") {
$error = "<li>You did not enter your name</li>\n";
}
if ($age == "") {
$error .= "<li>You did not enter your age</li>\n";
}
if ($email == "") {
$error .= "<li>You did not enter your email addres</li>\n";
}
if ($email != "" && ! preg_match ( '/^[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\\".[\]\x7f-\xff]+)+$/i', $email )) {
$error .= "<li>You did not enter a valid email address</li>\n";
}
if ($job == "") {
$error .= "<li>You did not enter the job your applying for</li>\n";
}
if ($message == "") {
$error .= "<li>You did not enter a message</li>\n";
}
if ($error) {
echo ("<p><strong>One of the following errors occured</strong>:<br>
<ul>
$error
</ul></p>");
} else {
$toemail = "[email protected]";
$subject = "Job Application from: $name";
$message = "<b>Name</b>: $name<br>
<b>Email</b>: $email<br>
<b>Age</b>: $age<br>
<b>Job</b>: $job<br>
<b>Message</b>: $message<br>
<b>IP Address</b>: $ip<br>
<b>Referer</b>: $referer<br>
<b>Browser</b>: $browser<br>
<b>Site</b>: $server";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: $name <$email>" . "\r\n";

if (mail ( $toemail, $subject, $message, $headers )) {
echo ("<p><strong>Thank You for your message!</strong></p>");
exit ();
}
}
}
?>
<form method="post">
<p><strong>* Full Name</strong>:<br>
<input name="name" value="<? echo $name; ?>" size="30" /><br>
<br>
<strong>* Age</strong>:<br>
<input name="age" value="<? echo $age; ?>" size="30" /><br>
<br>
<strong>* Email</strong>:<br>
<input name="email" value="<? echo $email; ?>" size="30" /><br>
<br>
<strong>* Job(&#39;s) applying for</strong>:<br>
<input name="job" value="<? echo $job; ?>" size="30" /><br>
<br>
<strong>* Why should you get it? Past experience.</strong>:<br>
<textarea name="message" cols="30" rows="5"><? echo $message; ?></textarea><br>
<br>
<input name="submit" type="submit" value="Apply" /></p>
</form>
</body>
</html>

Jamieb
02-02-2009, 07:47 PM
:DThanks Jack +rep is I can..

Moh
02-02-2009, 07:59 PM
:DThanks Jack +rep is I can..
Just remember to change the to email xD

Want to hide these adverts? Register an account for free!