Jump to content

PHP_SELF and Submit (on page open always submits)


programguru

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]

Link to comment
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>
<?
}
?>


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.