Jump to content

form thank you on same page


kayz100

Recommended Posts

Hi guys, my form works fine but I want the thank you message on the same page in red font, At the moment I am redirecting to thanks.htm and my form is on contme.php,

how do i do that?

script below:

<?php 
$Email_address ='sam@yahoo.com ';
session_start();
$errors = '';
$name = '';
$visitor_email = '';
$user_message = '';

if(isset($_POST['submit']))
{
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$user_message = $_POST['message'];


if(empty($name)||empty($visitor_email))
{
$errors .= "\n Name and Email are required fields. "; 
}
if(IsInjected($visitor_email))
{
$errors .= "\n Bad email value!";
}
if(empty($_SESSION['6_letters_code'] ) ||
 strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
$errors .= "\n The captcha code does not match!";
}
if(empty($errors))
{
$to = $Email_address;
$subject="loverman";
$from = $Email_address;
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';


$body = "$name contacted you by submitting the message below:\n\n".
"Name: $name\n\n".
"Email: $visitor_email \n\n".
"Message: \n\n ".
"$user_message\n\n".
"IP: $ip\n"; 


$headers = "From: $from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";


mail($to, $subject, $body,$headers);


//header('Location: ?success');
//echo "your enquiry was submitted successfully, thank you,";
header('Location: contme.php');
echo "Form submitted succesfully, thank you";
} else { 
echo "Form failed to send";
}
}


function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }
  else
    {
    return false;
  }
}
?>

 

Link to comment
Share on other sites

There is no redirect to a "thanks.htm" in that block which means either:

 

1. You're not showing everything.

 

Or

 

2. You aren't explaining your issue clearly enough.

 

Edit: You are however redirecting to contme.php, so why not just take that out?

Edited by SocialCloud
Link to comment
Share on other sites

The portion of your code below: 

//header('Location: ?success');
//echo "your enquiry was submitted successfully, thank you,";
header('Location: contme.php');
echo "Form submitted succesfully, thank you";
} else { 
echo "Form failed to send";
}
}

Change To:

//header('Location: ?success');
//echo "your enquiry was submitted successfully, thank you,";
header('Location: thanks.htm');
} else { 
echo "Form failed to send";
}
}
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.