madcrazy1 Posted October 18, 2008 Share Posted October 18, 2008 what is the proper formatting/syntax to add this code into the script at the bottom so that when the form is submitted it will execute this new new code via the form action=<? echo $PHP_SELF; ?> command. code to add to bottom script and execute on form action command: $subject = $_REQUEST["subject"]; $message = $_REQUEST["message"]; $from = $_REQUEST["from"]; $verif_box = $_REQUEST["verif_box"]; $message = stripslashes($message); $subject = stripslashes($subject); $from = stripslashes($from); mail("$ID", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from"); exit; } <form action="<? echo $PHP_SELF; ?>" method="post" name="form1" id="form1"> Your e-mail:<br /> <input name="from" type="text" id="from" value="<?php echo $_GET['from'];?>"/> <br /> Subject:<br /> <input name="subject" type="text" id="subject" value="<?php echo $_GET['subject'];?>"/> <br /> Message:<br /> <textarea name="message" cols="6" rows="5" id="message"><?php echo $_GET['message'];?></textarea> <input name="Submit" type="submit" value="Send Message"/> </form> </td></tr></table> Thanks for the help Quote Link to comment Share on other sites More sharing options...
madcrazy1 Posted October 18, 2008 Author Share Posted October 18, 2008 This is as far as i got, but it's not working: <? if($_POST['Submit']){ $subject = $_REQUEST["subject"]; $message = $_REQUEST["message"]; $from = $_REQUEST["from"]; $verif_box = $_REQUEST["verif_box"]; // remove the backslashes that normally appears when entering " or ' $message = stripslashes($message); $subject = stripslashes($subject); $from = stripslashes($from); if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page mail("$ID", 'Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from"); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true"); exit; }} ?> <center><font size="+1"><b>Contact Form</b></font></center> <br> <table align="center"><tr><td class="post_comments"><b> <form action="<? echo $PHP_SELF; ?>" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue"> Your e-mail:<br /> <input name="from" type="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:20px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:13px;" value="<?php echo $_GET['from'];?>"/> <br /> Subject:<br /> <input name="subject" type="text" id="subject" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px;" value="<?php echo $_GET['subject'];?>"/> <br /> Type the 4 Digits Shown: <input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px;"/> <img src="http://www.bizpup.com/contact/verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="75" height="50" align="center" /><br /> <!-- if the variable "wrong_code" is sent from previous page then display the error field --> <?php if(isset($_GET['wrong_code'])){?> <div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;">Wrong verification code</div><br /> <?php ;}?> Message:<br /> <textarea name="message" cols="6" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:300px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:13px;"><?php echo $_GET['message'];?></textarea> <input name="Submit" type="submit" style="margin-top:10px; display:block; border:1px solid #000000; width:100px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; line-height:14px; background-color:#EFEFEF;" value="Send Message"/> </form> </font></td></tr></table> <br/> </b></font> </body> </html> Quote Link to comment Share on other sites More sharing options...
philipolson Posted October 19, 2008 Share Posted October 19, 2008 Too much code to read, but the concept is simple: <?php if (empty($_POST['Submit'])) { // Show form } else { // Process form } ?> So, put the form where it says "Show form"... does this make sense? Quote Link to comment 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.