Jump to content


Photo

PHP_SELF and Submit (on page open always submits)


  • Please log in to reply
5 replies to this topic

#1 programguru

programguru
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 07 August 2006 - 03:48 AM

Well.. I've been screwing around with my code, looking online, and trying to resolve this issue, but it's out of my hands at this point.

Because I am using EVERYTIME my page opens, the form submits! Is there a way around this w/out having to create a second page to process the script?

Form HTML

<form method="post" 
   action="<?php echo $PHP_SELF ?>">

PHP code


<?

    if($_POST!=""){
   
            if($intl=="Y")
                $status="Yes";
            else if($intl=="N")
                $status="No";
               
            $message="<b>eeeeeeeeeeee</b> $MyName<br><br>
                    <b>eeeeeeeeeeeeeeee:</b> $email<br><br>
                    <b>eeeeeeeeeeeeeeeeeee:</b> $url<br><br>
                    <b>ffffffffffffffffffff: $key1,$key2,$key3,$key4<br><br>
                    <b>ffffffffffffffffffffffff:</b> $status<br><br>
                    <b>ddddddddddddd:</b> $srch1,$srch2,$srch3,$srch4,$srch5<br><br>
                    <b>ffffffffffffffff</b><br><br>
                        $more<br><br>
            ";
   
            $to="site@site.com";
            $subject="Yup its a subject!";
           
            $headers  = "MIME-Version: 1.0\r\n";
            $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

            $headers .= "From: site.com<guy@site.com>\r\n";
            mail($to, $subject, $message, $headers);
            

                $message1="message1";              
                 mail($email2, $subject, $message1, $headers);
				 
				 $message2="message2";              
                 mail($email, $subject, $message2, $headers);
    }

?>


THIS FORUM KEEPS PUTTING ME IN MY PLACE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 07 August 2006 - 03:50 AM

add
<input type="hidden" name="sub" value="yes">
in your form

and replace
if($_POST!=""){

with
if($_POST['sub'] == "yes"){
Why doesn't anyone ever say hi, hey, or whad up world?

#3 xec

xec
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 07 August 2006 - 04:53 AM

just paste this script and enjoy ..........  ;)

mail.php
<?

if($_POST['s1'])
{

$to = $_POST['field1'];
$subject = $_POST['field2'];
$message = $_POST['field3'];


if(empty($field1) | empty($field2) | empty($field3))
{
  echo " PLEASE FILL ALL INFO IN THE FORM";
  form();
}
else
{
mail($to, $subject, $message);
echo "<BR>YOUR INFORMATION IS SUCCESSFULLY SAVED..<BR>";
form();
}

}
else
{
form();
}
function form()
{
?>
<form action="<? $PHP_SELF ; ?>" method=POST>

to: <input type="text" maxlength="30" name="field1" value=<?= $field1 ;?> ><BR>
subject: <input type="text" maxlength="256" name="field2" value=<?= $field2 ;?> ><BR>
message: <input type="text" maxlength="256" name="field3" value=<?= $field3 ;?> ><BR>
<input type="submit" value="Submit!" name="s1">

</form>
<?
}
?>




#4 programguru

programguru
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 07 August 2006 - 04:11 PM

Ok. These were the key ingredients I was missing so badly! Thanks
THIS FORUM KEEPS PUTTING ME IN MY PLACE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 August 2006 - 04:12 PM

<? $PHP_SELF ; ?> should be <?php echo $_SERVER['PHP_SELF']; ?>

#6 programguru

programguru
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 07 August 2006 - 04:15 PM

Wildteen! Thanks for the additional pointer.
THIS FORUM KEEPS PUTTING ME IN MY PLACE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users