Jump to content

Form trouble


Sean_J

Recommended Posts

Hello Guys,

 

I created a basic email form using an online form generater. Instead on seeing a message saying "Success! Your email was sent!" . Would it be possible to redirect them to another page on my website? If so could someone please show me how as I am a complete novice?

 

The generator has come up with the following coding.

 

<?php

$EmailFrom = $_POST['EmailFrom'];

$name_ = Trim($_POST['name_']);

$age = Trim($_POST['age']);

$location = Trim($_POST['location']);

 

$EmailTo = "seanj@hotmail.com";

$Subject = ""; /// Add a subject

 

$validationOK=true;

if (Trim($EmailFrom)=="") $validationOK=false;

if (!$validationOK) {

  echo "Error! Email was not sent. Please check you code.";

  exit;

}

 

 

$Body = "";

$Body .= "Name :\n$name_\n\n";

$Body .= "Age:\n$age\n\n";

$Body .= "Location:\n$location\n\n";

 

if($Subject == NULL) {$Subject = "From $EmailFrom";}

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

 

if ($success){ echo "Success! Your email was sent!";}

else{  echo "Error! Your email was not sent!";}

 

?>

 

Thank you in advance

 

Sean

Link to comment
Share on other sites

Thank you for your replies.

 

Fesan,

 

Should the script look like this if I wanted to redirect them to my homepage

 

<?php

$EmailFrom = $_POST['EmailFrom'];

$name_ = Trim($_POST['name_']);

$age = Trim($_POST['age']);

$location = Trim($_POST['location']);

 

$EmailTo = "seanj@hotmail.com";

$Subject = ""; /// Add a subject

 

$validationOK=true;

if (Trim($EmailFrom)=="") $validationOK=false;

if (!$validationOK) {

  echo "Error! Email was not sent. Please check you code.";

  exit;

}

 

 

$Body = "";

$Body .= "Name :\n$name_\n\n";

$Body .= "Age:\n$age\n\n";

$Body .= "Location:\n$location\n\n";

 

if($Subject == NULL) {$Subject = "From $EmailFrom";}

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

 

if ($success){

header('location:*http://www.mysite.com/*');

}

else{  echo "Error! Your email was not sent!";}

 

?>

 

Thanks again

 

Sean

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.