Jump to content

Form to email


wright67uk

Recommended Posts

Im having trouble getting this form to work on my website.  It all seems to work ok, however when i test it, i dont recieve any emails to my inbox.  Godaddy seems to think that I am connecting to their server in the correct manner, but say that they cannot advise on customers codeing issues.  I thought that somebody in this forum maybe able to give me some pointers?

 

[<?php

ini_set('sendmail_from', '[email protected]');

ini_set('SMTP', 'relay-hosting.secureserver.net');

$subject = $_POST["subject"];

$message = $_POST["message"];

$from = $_POST["from"];

$name = $_POST["name"];

$phone = $_POST["phone"];

$verif_box = $_POST["verif_box"];

$subject = stripslashes($subject);

$message = stripslashes($message);

$from = stripslashes($from);

$name = stripslashes($name);

$phone = stripslashes($phone);

$embody = "$name $phone $message";

 

if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){

mail("[email protected]", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR'].$embody, "From: $from");

setcookie('tntcon','');

} else if(isset($message) and $message!=""){

header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");

exit;

} else {

echo "no variables received, this page cannot be accessed directly";

exit;

}

?>

<!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=iso-8859-1" />

<title>E-Mail Sent</title>

<style type="text/css">

<!--

body,td,th {

font-family: Arial, Helvetica, sans-serif;

font-size: 12px;

}

-->

</style></head>

 

<body>

Email sent. Thank you.<br />

<br />

Return to <a href="/">home page</a> ?

</body>

</html>]

Link to comment
https://forums.phpfreaks.com/topic/212029-form-to-email/
Share on other sites

I can give you a very simple working one.  It may help you out:

 

The form:

 

<form action="sendmail.php">

Name: <input name="name" type="text"><br>

Message: <input name="message" type="text"><br>

<input type="submit" value="Send">

</form>

 

The script:

 

<?php

  $name = $_REQUEST['name'] ;

  $message = $_REQUEST['message'] ;

 

  mail( "YOUREMAIL", "THESUBJECT",

    $message, "From: $name" );

  header( "Location: FORWARDURLGOESHERE" );

?>

Link to comment
https://forums.phpfreaks.com/topic/212029-form-to-email/#findComment-1105083
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.