Jump to content


Photo

Simple php verification


  • Please log in to reply
5 replies to this topic

#1 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 May 2006 - 04:43 AM

can anyone help me make it so that an is not sent unless the proper textboxes which would be the users email address and comments box is filled out

<?php
$to = "2fr3sh@gmail.com";
$subject = "$idea";
$from_header = "From: $from";

 

 mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

?>


#2 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 29 May 2006 - 04:51 AM



<?php
$to = "2fr3sh@gmail.com";
$subject = "$idea";
$from_header = "From: $from";

if (isset($to && $subject && $from_header)) {

 mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

}

?>



#3 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 May 2006 - 04:59 AM


<?php
$to = "2fr3sh@gmail.com";
$subject = "$idea";
$from_header = "From: $from";

if (isset($subject && $from_header)) {

mail($to, $subject, $contents, $from_header);
    
    echo 'Thank You, we will be sure to get back to you as soon as possible!';

}

else {
    echo 'Please go back and fill out the form';
}
 
?>



gives me the error

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Parse error: parse error, unexpected T_BOOLEAN_AND, expecting ',' or ')' in /hsphere/local/home/way2fr3s/2fr3sh.com/links/email.php on line 10

[/quote]

#4 witt

witt
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 29 May 2006 - 05:11 AM

Try it like so:

if (isset($subject) && ($from_header)) {


#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 29 May 2006 - 05:19 AM

Assuming that the form that gathered the information used method="post":

<?php
$subject = trim(strip_tags($_POST['idea']));
$from = trim(strip_tags($_POST['email']));
$contents = trim(strip_tags($_POST['contents']));

if (($from!="") && ($contents!="")) {
    $to = "2fr3sh@gmail.com";
    $from_header = "From: ". $from;
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "You forgot something";
}?>

Legend has it that reading the manual never killed anyone.
My site

#6 perezf

perezf
  • Members
  • PipPipPip
  • Advanced Member
  • 301 posts
  • LocationFort Lauderdale

Posted 29 May 2006 - 05:31 AM

it is gathered using post
but using the following code

<?php
    $subject = "$idea";


if (($from!="") && ($contents!="")) {
    $to = "2fr3sh@gmail.com";
    $from_header = "From: $from";
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "Please go back and fill the form out correctly";
 
?>

gives me the error message

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected $ in /hsphere/local/home/way2fr3s/2fr3sh.com/links/email.php on line 17
[/quote]

the code ended up working in the end
thank you to all for your help

<?php
$subject = trim(strip_tags($_POST['idea']));
$from_header = trim(strip_tags($_POST['from']));
$contents = trim(strip_tags($_POST['contents']));

if (($from!="") && ($contents!="")) {
    $to = "2fr3sh@gmail.com";
    $from_header = "From: ". $from;
    mail($to, $subject, $contents, $from_header);
    echo 'Thank You, we will be sure to get back to you as soon as possible!';
} else {
    echo "You forgot something";
}?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users