williamsk Posted January 17, 2008 Share Posted January 17, 2008 I've tried lots of stuff. I'm not a php guru (obviously) But i can't figure out what to put in the action field (it's full of question marks right now.) Can some one tackle this and help me out? <?php function is_valid_email_address($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } function getValue($pValue) { $returnValue = !empty($_POST[$pValue]) ? stripslashes(trim($_POST[$pValue])) : NULL; if( empty($returnValue)) { switch($pValue) { case "firstname": $returnValue = "First Name"; break; case "lastname": $returnValue = "Last Name"; break; case "phone_no": $returnValue = "Phone Number"; break; case "email_add": $returnValue = "Email Address"; break; } } return $returnValue; } $errors = array(); $formProcessed = FALSE; $fs = getValue("fs"); if(!empty($fs) && $fs == "y") { $confirm = getValue("confirm"); if( empty($confirm) || $confirm <> "yes" ) { $errors["confirm_required"] = "required"; } $firstname = getValue("firstname"); if( empty($firstname) || $firstname == "First Name" ) { $errors["firstname_required"] = "required"; } if( !ctype_alpha(str_replace(" ","",$firstname)) ) {$errors["firstname_not_string"] = "string"; } $lastname = getValue("lastname"); if( empty($lastname) || $lastname == "Last Name" ) { $errors["lastname_required"] = "required"; } if( !ctype_alpha(str_replace(" ","",$lastname)) ) {$errors["lastname_not_string"] = "string"; } $phone_no = getValue("phone_no"); if( empty($phone_no) || $phone_no == "Phone Number" ) { $errors["phone_no_required"] = "required"; } $email_add = getValue("email_add"); if( empty($email_add) || $email_add == "Email Address" ) { $errors["email_add_required"] = "required"; } else { if( !is_valid_email_address($email_add) ) { $errors["email_add_invalid"] = "invalid"; } } if( empty($errors)) { $formProcessed = TRUE; } } if( $formProcessed ) { $to = "[email protected]"; $headers = "From: [email protected]"; $subject = "Merchant Prospect Form Capture"; $message = "First Name: ".getValue("firstname")."\r\n"; $message = "Last Name: ".getValue("lastname")."\r\n"; $message.= "Phone Number: ".getValue("phone_no")."\r\n"; $message.= "Email Address: ".getValue("email_add")."\r\n"; mail($to,$subject,$message,$headers); ?> <div id="getContainer"> <img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" /> <p style="font-size:9px">Thank you! Someone from Rewards Network will be contacting you shortly.</p> </div> <?php } else { ?> <div id="getContainer"> <a href="#" onmouseover="showLayer('lyr5'); return false"><img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" /></a> <?php if( empty($errors)) { ?> <div id="lyr5"> <?php } else { ?> <div id="lyr5" style="visibility: visible;"> <?php } ?> <a href="#" onclick="hideLayer('lyr5'); return false"><img src="images/bttn_close.gif" alt="CLOSE" width="11" height="9" border="0" align="right" /></a> <p> </p> <p> Want to get started right away? A representative will contact you. </p><br /> <form name="get_started" id="get_started" action="????????" method="post"> <input type="hidden" name="fs" value="y" /> <input type=hidden name="oid" value="00D500000007WCl" /> <input type=hidden name="retURL" value="http://localhost/rcr/thank_you.htm" /> <input type=hidden name="lead_source" value="Web" /> <p align="right"><small>[All fields required.]</small></p> <?php if(!empty($errors["firstname_required"])) { ?><p class="error-red">First Name is required</p><?php } ?> <?php if(!empty($errors["firstname_not_string"])) { ?><p class="error-red">First Name can only contain letters</p><?php } ?> <input name="first_name" id="firstname" maxlength="100" size="23" value="<?php echo getValue("firstname");?>" onfocus="value=''" /><br /> <?php if(!empty($errors["lastname_required"])) { ?><p class="error-red">Last Name is required</p><?php } ?> <?php if(!empty($errors["lastname_not_string"])) { ?><p class="error-red">Last Name can only contain letters</p><?php } ?> <input name="last_name" id="lastname" maxlength="100" size="23" value="<?php echo getValue("lastname");?>" onfocus="value=''" /><br /> <?php if(!empty($errors["phone_no_required"])) { ?><p class="error-red">Phone Number is required</p><?php } ?> <input name="phone" id="phone_no" maxlength="100" size="23" value="<?php echo getValue("phone_no");?>" onfocus="value=''" /><br /> <?php if(!empty($errors["email_add_required"])) { ?><p class="error-red">Email Address is required</p><?php } ?> <?php if(!empty($errors["email_add_invalid"])) { ?><p class="error-red">Email Address is not properly formed</p><?php } ?> <input name="email" id="email_add" maxlength="100" size="23" value="<?php echo getValue("email_add");?>" onfocus="value=''" /><br /> <table cellpadding="5"> <tr> <td colspan="2"> <br /> <p style="font-size:9px"> Contact us ASAP at 800-422-5155 </p> </td> </tr> <?php if(!empty($errors["confirm_required"])) { ?> <tr><td valign="top" colspan="2"><span class="error-red">You must check the box below</span></td></tr> <?php } ?> <tr> <td valign="top"> <input type="checkbox" name="confirm" id="confirm" value="yes" /> </td> <td valign="top"> <p style="font-size:9px"> I agree to the terms and conditions as listed in the <a href="terms_conditions.php" onclick= "OpenSmall(this.href); return false">Web site Terms of Use</a> and consent to the collection and use of my personal information in accordance with our <a href="privacy_policy.php" onclick= "OpenSmall(this.href); return false">Privacy Policy</a>. </p> </td> </tr> </table><br /> <input name="submit" type="image" src="images/bttn_submit.gif" alt="Submit" align="right" /> </form> </div> </div> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/ Share on other sites More sharing options...
tinker Posted January 17, 2008 Share Posted January 17, 2008 You put the link as to where you want the form to be sent, if it's itself, then either leave it blank, put in an absolute or relative filename, or use $_SERVER['PHP_SELF'] Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441945 Share on other sites More sharing options...
soycharliente Posted January 17, 2008 Share Posted January 17, 2008 Please use the code tag to wrap your smut. It's the button with the # symbol on it. It will it in a box and make it a bit easier on the eyes. Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441947 Share on other sites More sharing options...
williamsk Posted January 17, 2008 Author Share Posted January 17, 2008 Sorry I've tried lots of stuff. I'm not a php guru (obviously) But i can't figure out what to put in the action field (it's full of question marks right now.) Can some one tackle this and help me out? <?php function is_valid_email_address($email){ return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } function getValue($pValue) { $returnValue = !empty($_POST[$pValue]) ? stripslashes(trim($_POST[$pValue])) : NULL; if( empty($returnValue)) { switch($pValue) { case "firstname": $returnValue = "First Name"; break; case "lastname": $returnValue = "Last Name"; break; case "phone_no": $returnValue = "Phone Number"; break; case "email_add": $returnValue = "Email Address"; break; } } return $returnValue; } $errors = array(); $formProcessed = FALSE; $fs = getValue("fs"); if(!empty($fs) && $fs == "y") { $confirm = getValue("confirm"); if( empty($confirm) || $confirm <> "yes" ) { $errors["confirm_required"] = "required"; } $firstname = getValue("firstname"); if( empty($firstname) || $firstname == "First Name" ) { $errors["firstname_required"] = "required"; } if( !ctype_alpha(str_replace(" ","",$firstname)) ) {$errors["firstname_not_string"] = "string"; } $lastname = getValue("lastname"); if( empty($lastname) || $lastname == "Last Name" ) { $errors["lastname_required"] = "required"; } if( !ctype_alpha(str_replace(" ","",$lastname)) ) {$errors["lastname_not_string"] = "string"; } $phone_no = getValue("phone_no"); if( empty($phone_no) || $phone_no == "Phone Number" ) { $errors["phone_no_required"] = "required"; } $email_add = getValue("email_add"); if( empty($email_add) || $email_add == "Email Address" ) { $errors["email_add_required"] = "required"; } else { if( !is_valid_email_address($email_add) ) { $errors["email_add_invalid"] = "invalid"; } } if( empty($errors)) { $formProcessed = TRUE; } } if( $formProcessed ) { $to = "[email protected]"; $headers = "From: [email protected]"; $subject = "Merchant Prospect Form Capture"; $message = "First Name: ".getValue("firstname")."\r\n"; $message = "Last Name: ".getValue("lastname")."\r\n"; $message.= "Phone Number: ".getValue("phone_no")."\r\n"; $message.= "Email Address: ".getValue("email_add")."\r\n"; mail($to,$subject,$message,$headers); ?> <div id="getContainer"> <img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" /> <p style="font-size:9px">Thank you! Someone from Rewards Network will be contacting you shortly.</p> </div> <?php } else { ?> <div id="getContainer"> <a href="#" onmouseover="showLayer('lyr5'); return false"><img src="images/bttn_getstarted.gif" alt="Get Started" width="166" height="13" border="0" /></a> <?php if( empty($errors)) { ?> <div id="lyr5"> <?php } else { ?> <div id="lyr5" style="visibility: visible;"> <?php } ?> <a href="#" onclick="hideLayer('lyr5'); return false"><img src="images/bttn_close.gif" alt="CLOSE" width="11" height="9" border="0" align="right" /></a> <p> </p> <p> Want to get started right away? A representative will contact you. </p><br /> <form name="get_started" id="get_started" action="????????" method="post"> <input type="hidden" name="fs" value="y" /> <input type=hidden name="oid" value="00D500000007WCl" /> <input type=hidden name="retURL" value="http://localhost/rcr/thank_you.htm" /> <input type=hidden name="lead_source" value="Web" /> <p align="right"><small>[All fields required.]</small></p> <?php if(!empty($errors["firstname_required"])) { ?><p class="error-red">First Name is required</p><?php } ?> <?php if(!empty($errors["firstname_not_string"])) { ?><p class="error-red">First Name can only contain letters</p><?php } ?> <input name="first_name" id="firstname" maxlength="100" size="23" value="<?php echo getValue("firstname");?>" onfocus="value=''" /><br /> <?php if(!empty($errors["lastname_required"])) { ?><p class="error-red">Last Name is required</p><?php } ?> <?php if(!empty($errors["lastname_not_string"])) { ?><p class="error-red">Last Name can only contain letters</p><?php } ?> <input name="last_name" id="lastname" maxlength="100" size="23" value="<?php echo getValue("lastname");?>" onfocus="value=''" /><br /> <?php if(!empty($errors["phone_no_required"])) { ?><p class="error-red">Phone Number is required</p><?php } ?> <input name="phone" id="phone_no" maxlength="100" size="23" value="<?php echo getValue("phone_no");?>" onfocus="value=''" /><br /> <?php if(!empty($errors["email_add_required"])) { ?><p class="error-red">Email Address is required</p><?php } ?> <?php if(!empty($errors["email_add_invalid"])) { ?><p class="error-red">Email Address is not properly formed</p><?php } ?> <input name="email" id="email_add" maxlength="100" size="23" value="<?php echo getValue("email_add");?>" onfocus="value=''" /><br /> <table cellpadding="5"> <tr> <td colspan="2"> <br /> <p style="font-size:9px"> Contact us ASAP at 800-422-5155 </p> </td> </tr> <?php if(!empty($errors["confirm_required"])) { ?> <tr><td valign="top" colspan="2"><span class="error-red">You must check the box below</span></td></tr> <?php } ?> <tr> <td valign="top"> <input type="checkbox" name="confirm" id="confirm" value="yes" /> </td> <td valign="top"> <p style="font-size:9px"> I agree to the terms and conditions as listed in the <a href="terms_conditions.php" onclick= "OpenSmall(this.href); return false">Web site Terms of Use</a> and consent to the collection and use of my personal information in accordance with our <a href="privacy_policy.php" onclick= "OpenSmall(this.href); return false">Privacy Policy</a>. </p> </td> </tr> </table><br /> <input name="submit" type="image" src="images/bttn_submit.gif" alt="Submit" align="right" /> </form> </div> </div> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441958 Share on other sites More sharing options...
tinker Posted January 17, 2008 Share Posted January 17, 2008 did you read my previous reply? Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441961 Share on other sites More sharing options...
williamsk Posted January 17, 2008 Author Share Posted January 17, 2008 But when I send it to itself, it seems to refresh and the form errors come up as if i never filled anything out. And no email is sent?? Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441963 Share on other sites More sharing options...
tinker Posted January 17, 2008 Share Posted January 17, 2008 you only asked what to put in the action field, didn't even say that it was to call itself, I had to figure that out myself. Next, what are the error's your getting? Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441967 Share on other sites More sharing options...
williamsk Posted January 17, 2008 Author Share Posted January 17, 2008 The fields are set to show errors if they are not filled in. When it's set to send to itself, I hit submit and instead of sending the form, the errors on the fields show up saying I didn't fill anything out, but i did. Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441972 Share on other sites More sharing options...
roopurt18 Posted January 17, 2008 Share Posted January 17, 2008 Is there a separate script that already exists on the server that processes this form? Are you writing this from scratch? Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441987 Share on other sites More sharing options...
tinker Posted January 17, 2008 Share Posted January 17, 2008 What a * nightmare to debug! getValue("firstname") That's calling the id name not the name, e.g. getValue("first_name") sort of works... but it needs work! Link to comment https://forums.phpfreaks.com/topic/86489-this-is-killing-me/#findComment-441996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.