Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

Form Check

Links for php scripts

Moderators: macek, egami, gesf

Form Check

Postby aantaya » Sun Mar 12, 2006 8:38 am

Ok So creating a newsletter sign up from, and When the info is sent to my next page, It pretty much checks it. But It does not stop the message from being sent to email. Anyone have any ideas why. I am totally lost

Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->
<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($firstname) || empty($visitormail) || empty($address)) {
echo "<h2>Use Back - fill in all required fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;
$subject = "Info Request";
$goals = stripcslashes($goals);
$message = " $todayis [EST] \n
Message: Info Request \n
From: $firstname ($visitormail)\n
Name: $firstname $lastname \n
Address: $address \n
$city , $state $zip \n
Country: $country \n
Email: $visitormail \n
Hphone: $hphone \n
Wphone: $wphone \n
IntPhone: $intphone \n
Age: $age \n
Hear From: $heard, $heard2 \n
Film Goals: $goals \n
Film Experience: $experience \n
";

$from = "From: $visitormail\r\n";

mail("aantaya@hotmail.com", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $firstname ?> ( <?php echo $visitormail ?> )
<br>
Your Information request well be sent out soon.
<br />
<br />
</p>

</body>
</html>
aantaya
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Mar 12, 2006 8:35 am

Postby revq » Sun Mar 12, 2006 11:37 pm

You are checking the input for missing fields and if you find it you are echoing an error message and then allowing the script to continue running. What you need to do is to stop it from running, by adding "exit;" to the code, like this :-
Code: Select all
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
  echo "<h2>Use Back - Enter valid e-mail</h2>\n";
  echo "<h2>Feedback was NOT submitted</h2>\n";
  exit;
}


Note also that $badinput was changed to echo
User avatar
revq
New php-forum User
New php-forum User
 
Posts: 21
Joined: Mon Feb 13, 2006 1:54 am
Location: South Africa

Thanks

Postby aantaya » Mon Mar 13, 2006 6:09 am

Hey thanks alot. that check is working.. But now it will not send. I can not figure out why. I have tested the check and it works. but when everything is good and correct the part where it is supposed to send out the email does not work.. any thoughts. I am lost.

By the way. I am very new to all this and I am in your debt for helping me!

Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>
<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->
<?php

if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
  echo "<h2>Use Back - Enter valid e-mail</h2>\n";
  echo "<h2>Feedback was NOT submitted</h2>\n";
  exit;
}
if(empty($firstname) || empty($visitormail) || empty($address))
{
   echo "<h2>Use Back - fill in all required fields</h2>\n";
   echo "<h2>Feedback was NOT submitted</h2>\n";
   exit;
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;
$subject = "Info Request";
$goals = stripcslashes($goals);
$message = " $todayis [EST] \n
Message: Info Request \n
From: $firstname ($visitormail)\n
Name: $firstname $lastname \n
Address: $address \n
$city , $state $zip \n
Country: $country \n
Email: $visitormail \n
Hphone: $hphone \n
Wphone: $wphone \n
IntPhone: $intphone \n
Age: $age \n
Hear From: $heard, $heard2 \n
Film Goals: $goals \n
Film Experience: $experience \n
";

$from = "From: $visitormail\r\n";

mail("aantaya@hotmail.com", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $firstname ?> ( <?php echo $visitormail ?> )
<br>
Your Information request well be sent out soon.
<br />
<br />
</p>

</body>
</html>
aantaya
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Mar 12, 2006 8:35 am

IT WORKS!!

Postby aantaya » Mon Mar 13, 2006 10:39 am

Ok so It does work after all.. just a server issue sending it I think but everything is good to go now... Thanks For your help revq it is greatly appriciated!!!
aantaya
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sun Mar 12, 2006 8:35 am


Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron