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', 'user@domain.tld');

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("ed@treework.net", '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
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
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.