programguru Posted August 7, 2006 Share Posted August 7, 2006 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="[email protected]"; $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<[email protected]>\r\n"; mail($to, $subject, $message, $headers); $message1="message1"; mail($email2, $subject, $message1, $headers); $message2="message2"; mail($email, $subject, $message2, $headers); }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16759-php_self-and-submit-on-page-open-always-submits/ Share on other sites More sharing options...
corbin Posted August 7, 2006 Share Posted August 7, 2006 add<input type="hidden" name="sub" value="yes">in your formand replaceif($_POST!=""){with if($_POST['sub'] == "yes"){ Quote Link to comment https://forums.phpfreaks.com/topic/16759-php_self-and-submit-on-page-open-always-submits/#findComment-70468 Share on other sites More sharing options...
xec Posted August 7, 2006 Share Posted August 7, 2006 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><?}?> Quote Link to comment https://forums.phpfreaks.com/topic/16759-php_self-and-submit-on-page-open-always-submits/#findComment-70480 Share on other sites More sharing options...
programguru Posted August 7, 2006 Author Share Posted August 7, 2006 Ok. These were the key ingredients I was missing so badly! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/16759-php_self-and-submit-on-page-open-always-submits/#findComment-70739 Share on other sites More sharing options...
wildteen88 Posted August 7, 2006 Share Posted August 7, 2006 <? $PHP_SELF ; ?> should be <?php echo $_SERVER['PHP_SELF']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/16759-php_self-and-submit-on-page-open-always-submits/#findComment-70740 Share on other sites More sharing options...
programguru Posted August 7, 2006 Author Share Posted August 7, 2006 Wildteen! Thanks for the additional pointer. Quote Link to comment https://forums.phpfreaks.com/topic/16759-php_self-and-submit-on-page-open-always-submits/#findComment-70742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.