Jump to content

Archived

This topic is now archived and is closed to further replies.

programguru

PHP_SELF and Submit (on page open always submits)

Recommended Posts

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?

[b]Form HTML[/b]

[code] <form method="post"
  action="<?php echo $PHP_SELF ?>">[/code]
[b]
PHP code[/b]

[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);
    }

?>[/code]

Share this post


Link to post
Share on other sites
add
<input type="hidden" name="sub" value="yes">
in your form

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

with
if($_POST['sub'] == "yes"){

Share this post


Link to post
Share on other sites
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>
<?
}
?>


Share this post


Link to post
Share on other sites
<? $PHP_SELF ; ?> should be <?php echo $_SERVER['PHP_SELF']; ?>

Share this post


Link to post
Share on other sites

×

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.