Captcha verify leads to form being erased. HELP

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

70 Replies - 7654 Views - Last Post: 18 May 2011 - 02:17 PM Rate Topic: -----

#1 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Captcha verify leads to form being erased. HELP

Posted 29 April 2011 - 05:23 PM

Hello, I have been looking around for about two hours for a solution to my problem. I have a form on my website that of course has a "captcha" at the bottom. I have java check the required sections of the form to make sure it is entirely filled out before it can be submitted. The problem is, if you get the security code wrong, you are redirected back to the same quote page using
<?php session_start(); 
if((@$_POST['check']) == @$_SESSION['check']) { 
echo"<script>window.location = '../thankyou.php'</script>";
}else{ 
echo"<center><font size=\"1\" face=\"tahoma\" color=\"black\">Wrong Security Text <a href=\"javascript:history.go(-1)\">Go Back</a></font></center>";  
die();      
} 
but results in all the information that was initially typed in to be deleted. I obviously cannot make it so the captcha gets verified though javascript on serverside because that would do nothing to prevent bots. Is there a way that I can store the info type in by the user and have it automatically reload into the form if they get the security code wrong?

Here is the direct link to the quote I made that I am having problems with. It would probably be easier to just go there and fill out the form with the wrong security code to see what I mean.

http://www.contracto...y.com/quote.php

Thanks so much, I am new to these forums and I will try to do anything in my power to help you guys help me :P

Here is the entire code of the .php file that you get redirected to after filling out the form:

<?php session_start(); 
if((@$_POST['check']) == @$_SESSION['check']) { 
echo"<script>window.location = '../thankyou.php'</script>";
}else{ 
echo"<center><font size=\"1\" face=\"tahoma\" color=\"black\">Wrong Security Text <a href=\"javascript:history.go(-1)\">Go Back</a></font></center>";  
die();      
}
/* Subject and Email Variables */

	$emailSubject = 'Customer: Request An Estimate';
	$webMaster = 'xxxx@xxxx.com';
	
/* Gathering Data Variables */

	$requestField = $_POST['request'];
	$descriptionField = $_POST['message'];
	$first_nameField = $_POST['first_name'];
	$last_nameField = $_POST['last_name'];
	$current_addressField = $_POST['current_address'];
	$current_cityField = $_POST['current_city'];
	$current_stateField = $_POST['current_state'];
	$current_zipField = $_POST['current_zip'];
	$current_address_lengthField = $_POST['current_address_length'];
	$previous_addressField = $_POST['previous_address'];
	$previous_cityField = $_POST['previous_city'];
	$previous_stateField = $_POST['previous_state'];
	$previous_zipField = $_POST['previous_zip'];
	$primary_area_codeField = $_POST['primary_area_code'];
	$primary_phone_numberField = $_POST['primary_phone_number'];
	$secondary_area_codeField = $_POST['secondary_area_code'];
	$secondary_phone_numberField = $_POST['secondary_phone_number'];
	$email_addressField = $_POST['email_address'];
	$best_contactField = $_POST['best_contact'];
	
	$body = <<<EOD
<strong>$requestField ESTIMATE REQUEST</strong>
<br><hr><br>
<strong>REQUEST DETAILS:</strong>
<br>
<strong>Request is For:</strong> $requestField <br>
<strong>Type of Request:</strong> $typeField <br>
<strong>Description:</strong> $descriptionField <br>
<br>
<strong>Title:</strong> $titleField <br>
<strong>First Name:</strong> $first_nameField <br>
<strong>Last Name:</strong> $last_nameField <br>
<strong>Address:</strong> $addressField <br>
<strong>City:</strong> $cityField <br>
<strong>State:</strong> $stateField <br>
<strong>Postal Code:</strong> $zipField <br>
<br>
<strong>Best Way to Contact:</strong> $best_contactField <br>
<strong>Email Address:</strong> $email_addressField <br>
<strong>Contact Phone Number:</strong> ($primary_area_codeField)$primary_phone_numberField <br>
<strong>Evening Phone Number:</strong> ($secondary_area_codeField)$secondary_phone_numberField <br>
EOD;

	$headers = "From: $email\r\n";
	$headers .= "Content-type: text/html\r\n";
	$success = mail($webMaster, $emailSubject, $body, $headers);
	
/* Results rendered as HTML */

	$theResults = <<<EOD

EOD;
echo "$theResults";

?>


and here is the actual form page that the link i provided brings you to:
<div class="post">
                            <div class="entry">
                              <center>
                                <form id="form1" method="post" action="../scripts/contactforumprocess.php">
<table width="100%" border="0" cellpadding="6">
                                    		          <tr>
		            <td width="53%" align="left"><label for="request"><strong>Request is for:</strong></label></td>
		            <td width="47%" align="left"><font color="#FF0000"><span id="spryselect1">
	                <select name="request" id="request">
	                  <option value="">-- Please Select --</option>
	                  <option value="Bathroom">Bathroom</option>
	                  <option value="Kitchen">Kitchen</option>
	                  <option value="Accessibility">Accessibility</option>
	                  <option value="Windows">Windows</option>
	                  <option value="Decks">Decks</option>
	                  <option value="Siding">Siding</option>
	                  <option value="Other">Other</option>
                    </select>
	                <span class="selectRequiredMsg">Required</span></span> *</font></td>
	              </tr>
		          <tr>
		            <td align="left"><label for="type"><strong>Type of Request:</strong></label></td>
		            <td align="left">
	                <font color="#FF0000"><span id="spryselect2">
	                <label for="type"></label>
	                <select name="type" id="type">
	                  <option value="">-- Please Select --</option>
	                  <option value="Estimate">Estimate</option>
	                  <option value="Information">Information</option>
                    </select>
	                <span class="selectRequiredMsg">Required</span></span> *</font></td>
	              </tr>                                    
                                    <tr>
                                      <td width="53%" align="left"><label for="message"><strong>Brief Description: </strong><br />
                                      <font color="#999999">(Please include as much information as possible, including budget, size, color(s), terms, etc.)</font></label></td>
                                      <td width="47%" align="left"><span id="sprytextarea1">
                                        <textarea name="description" id="description" cols="27" rows="5"></textarea>                             
</span><font color="#FF0000">*</font></td>
                                    </tr>
                                    <tr>
                                      <td align="left"><label for="first_name"><strong>Name:</strong></label>
                                      
                                      <br> 
                                      <font color="#999999">(Title, First Name, Last Name)</font></p></td>
      <td align="left">
        <label for="title"></label>
        <span id="spryselect3">
        <select name="title" id="title">
        <option value="">Title</option>
        <option value="Mr.">Mr.</option>
	    <option value="Mrs.">Mrs.</option>
        <option value="Miss">Miss</option>
        </select></span>
        <font color="#FF0000"><span id="sprytextfield1">
        <input type="text" name="first_name" id="first_name" size="11" maxlength="40"  />
        </span>
        <span id="sprytextfield2">
        <input name="last_name" type="text" id="last_name" size="11" maxlength="40" />
        </span>
        <label for="first_name"></label>
                    *</font></p></td>
                                    </tr>
                                    <tr>
                                      <td align="left"><strong>Please have responses to my request sent to:</strong></td>
                                      <td align="left">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td align="left"><strong>
                                        <label for="best_contact">Best Way to Contact Me:</label>
                                      </strong></td>
                                      <td align="left"><span id="spryselect4">
                                        <select name="best_contact" id="best_contact">
                                          <option>No Preference</option>
                                          <option>Phone</option>
                                          <option>Email</option>
                                        </select>
</span></td>
                                    </tr>
                                    <tr>
		            <td align="left"><label for="time"><strong>Best Time to Reach Me:<br />
		              </strong><font color="#999999">(Leave unchecked if you have &quot;No Preference&quot;)</font>
		              </p>
		            </label></td>
		            <td align="left">
		              
                    <span id="spryselect5">
                    <select name="from_time" id="from_time">
                      <option>No Preference</option>
                      <option>8:00am</option>
                      <option>9:00am</option>
                      <option>11:00am</option>
                      <option>12:00pm</option>
                      <option>1:00pm</option>
                      <option>2:00pm</option>
                      <option>3:00pm</option>
                      <option>4:00pm</option>
                      <option>5:00pm</option>
                      <option>6:00pm</option>
                      <option>7:00pm</option>
                      <option>8:00pm</option>
                      <option>9:00pm</option>
                      <option>10:00pm</option>
                    </select></span> -
                    <span id="spryselect6">
                    <select name="until_time" id="until_time">
                      <option>No Preference</option>
                      <option>9:00am</option>
                      <option>11:00am</option>
                      <option>12:00pm</option>
                      <option>1:00pm</option>
                      <option>2:00pm</option>
                      <option>3:00pm</option>
                      <option>4:00pm</option>
                      <option>5:00pm</option>
                      <option>6:00pm</option>
                      <option>7:00pm</option>
                      <option>8:00pm</option>
                      <option>9:00pm</option>
                      <option>10:00pm</option>
                    </select>
</span><br>

                     <label>
                      <input name="week_day_" type="checkbox" id="week_day_1" value="Mon."/>
                      M</label>
                    <label>
	                  <input type="checkbox" name="week_day" value="Tue." id="week_day_2" />T</label>
		              <label>
		                <input type="checkbox" name="week_day" value="Wed." id="week_day_3" />W</label>
		              <label>
		                <input type="checkbox" name="week_day" value="Thu." id="week_day_4" />Th</label>
		              <label>
		                <input type="checkbox" name="week_day" value="Fri." id="week_day_5" />F</label>
		              <label>
		                <input type="checkbox" name="week_day" value="Sat." id="week_day_6" />S</label>
		              <label>
		                <input type="checkbox" name="week_day" value="Sun." id="week_day_7" />Su</label></span>
</td>
                                    </tr>
                                    <tr>
                                      <td align="left"><strong>
                                        <label for="phone">Primary Phone Number</label>
                                        :<br />
                                      </strong><font color="#999999">(3 digit Area Code followed by an 8 digit number)</font>
                                      </p></td>
                                      <td align="left"><span id="sprytextfield3">
                                      <input name="primary_area_code" type="text" id="primary_area_code" size="1" maxlength="3" />
                                      <span class="textfieldInvalidFormatMsg">Invalid format</span><span class="textfieldMinCharsMsg">Need 3 digit area code</span></span>
                                        <span id="sprytextfield4">
                                        <input name="primary_phone_number" type="text" id="primary_phone_number" size="6" maxlength="7" />
                                        <span class="textfieldRequiredMsg">Required</span><span class="textfieldMinCharsMsg">Need 7 digit number</span><span class="textfieldInvalidFormatMsg">Invalid format</span></span> <font color="#FF0000">*</font></td>
                                    </tr>
                                    <tr>
                                      <td align="left"><strong>
                                        <label for="secondary_phone_number">Secondary Phone Number</label>
                                        :<br />
                                      </strong><font color="#999999">(3 digit Area Code followed by an 8 digit number)</font>
                                      </p></td>
                                      <td align="left"><span id="sprytextfield7">
                                        <input name="secondary_area_code" type="text" id="secondary_area_code" size="1" maxlength="3" />
                                      <span class="textfieldInvalidFormatMsg">Invalid format</span><span class="textfieldMinCharsMsg">Need 3 digit area code</span></span><span id="sprytextfield8">
                                      <input name="secondary_phone_number" type="text" id="secondary_phone_number" size="6" maxlength="7" />
                                      <span class="textfieldMinCharsMsg">Need 7 digit number</span><span class="textfieldInvalidFormatMsg">Invalid format</span></span></td>
                                    </tr>
                                    <td align="left"><strong>
                                        <label for="email">Email Address:</label>
                                      </strong></td>
                                      <td align="left"><span id="sprytextfield5">
                                      <input name="email_address" type="text" id="email_address" onblur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" size="25" maxlength="100" />
                                      <span class="textfieldInvalidFormatMsg">Invalid format</span><span class="textfieldRequiredMsg">Required</span></span><font color="#FF0000">*</font></td>
<tr>
                                      <td align="right"><img src="captcha.php" id="img" border="0" title="Captcha">
</td>
                                      <td align="left"><span id="sprytextfield6">
                                        <input name="check" type="text" id="check" style="font-size:14px;font-family:'Trebuchet MS';font-weight:bold;color:#4D4D4E;border:#ccc 2px dotted;" size="1" maxlength="2"/>
                                      <span class="textfieldRequiredMsg">Required</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><font color="#FF0000">*</font><br>
<i style="font-family:'trebuchet ms';font-size:12px;">Please enter security code</i> <a href="javascript:poptastic('http://www.metacalc.com/');">Click for Calculator</a> 
</td>
                </tr>
                                    <tr>
                                      <td align="right"><label for="submit"></label>
                                        <input name="submit" type="submit" id="submit" onclick="MM_validateForm('first_name','','R','last_name','','R','email_address','','RisEmail','contact_area_code','','NisNum','evening_area_code','','NisNum','check','','RisNum','message','','R');return document.MM_returnValue" value="SEND REQUEST" /></td>
                                      <td align="left"><label for="clear"></label>
                                        <input type="reset" name="clear" id="clear" value="CLEAR FORM" /></td>
                                    </tr>
                                  </table>
                                </form>
                                <table width="100%" border="0" cellpadding="6">
                                  <tr>
                                    <td align="center"><font color="#FF0000">*</font> Are Required Fields</td>
                                  </tr>
                                </table>
                              </center>
                            </div>

          
	  </div>


Is This A Good Question/Topic? 0
  • +

Replies To: Captcha verify leads to form being erased. HELP

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 927
  • View blog
  • Posts: 3,209
  • Joined: 19-January 10

Re: Captcha verify leads to form being erased. HELP

Posted 29 April 2011 - 06:19 PM

REMOVE THE @ SYMBOLS.

They are worthless and slow. Finished code should not have any errors in it. Adding these also make it VERY hard to figure out what the problem is. Also add error_reporting(E_ALL); at the top of each file and tell us any errors it reports.
Was This Post Helpful? 1
  • +
  • -

#3 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 29 April 2011 - 09:22 PM

View Postcreativecoding, on 29 April 2011 - 06:19 PM, said:

REMOVE THE @ SYMBOLS.

They are worthless and slow. Finished code should not have any errors in it. Adding these also make it VERY hard to figure out what the problem is. Also add error_reporting(E_ALL); at the top of each file and tell us any errors it reports.


really? the @ symbols do nothing? I just got this script from somewhere else and slightly modified it. Can you explain a little better on how to do the error_reporting thing? I am somewhat new at PHP.. I am more of the take a file and modify it until it does what I need it to do.. I can't go and make something from scratch. Any help would be appreciated, at least telling me if I could do what I am trying to do by making the data save in PHP sessions or something? Anything would help.. I just spent a while making that form and I just realized that if anyone goofs up on the captcha then they have to completely retype everything. I am making this site for a business and I know if someone messes up resulting in them to have to retype everything, they might just get up and leave. Any help would be greatly appreciated, just try and work with me because I am in no way an expert with PHP, still pretty new with it. I have been modifying it for over 5 or 6 months though, but we all know that isn't the same. Thanks! [:
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,548
  • Joined: 23-August 08

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 04:57 AM

You've been working with this for 5 or 6 months and you haven't even bothered to learn PHP? Sigh. Copying and pasting code you glean from the Internet is a fine way to set up a site ripe for attack. Not knowing what you're doing will be your downfall.

The PHP Manual
The section on error reporting
Was This Post Helpful? 4
  • +
  • -

#5 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 10:22 AM

View PostJackOfAllTrades, on 30 April 2011 - 04:57 AM, said:

You've been working with this for 5 or 6 months and you haven't even bothered to learn PHP? Sigh. Copying and pasting code you glean from the Internet is a fine way to set up a site ripe for attack. Not knowing what you're doing will be your downfall.

The PHP Manual
The section on error reporting


It's my part time job that I am doing on the side while going to school for management and marketing.. I'm sory but I did not come to these forums to get told what I am doing is terribly wrong and that is what is going to be my "downfall". I understand that it is not the best way not knowing PHP like the back of my hand, but guess what? Its not really that easy for my to find time to teach myself everything. Down the line when I am less busy I might find myself doing it, but keep in mind that I am going to school for BUSINESS and MARKETING not computers or web design. I will figure out PHP down the line, but right now I am just getting extremely flustered about this form thing. There is no "problem" I have to find with it which is what I feel you guys are trying to make me find, the issue is that it wont retain the values put in but that is because I have the values get checked serverside with javascript. I just want to make it so the info put in will be retained when refreshed or just simply gone back. From reading around a lot, I have heard you can do this with SESSIONS and/or COOKIES. Because I am using PHP I heard that SESSIONS work better, but what I am asking for is help.. Not exactly an entire booklet on how to learn PHP from scratch. I just want to get this form up and working so everything is happy then I will proceed to learn PHP from scratch when I have time. I know it isn't the best way to do everything, but I am making due with the amount of time I have. I do appreciate your help, but I feel like this is more of an "attack" than anything else. Thanks for the @ info I didn't know about that, but the error reporting, what would that even do to help what I am currently trying to do? I am not encountering an error.. It just is not retaining the information because of the method I chose to verify the info. I just want help with that and after I am done with that I can spend some free time doing other stuff like this "error" thing and learning PHP. I really do appreciate it guys, but again I didn't come here to hear "you are doing everything wrong" blah blah blah because quite frankly I am not stupid, I know that the way I am doing everything probably is NOT the best way or the SAFEST or anything.. BUT it works and that is what makes my boss happy which is good enough for me. I have spent a lot of time researching this problem and there seems to be no straightforward answer but I know that people had to have used Dreamweavers SPRY validation and fixed the current issue I am facing because I have been to sites and saw that if you encounter a captcha error, it redirects me to the same page (different looking URL) but retains all of my data in there.

Again, thanks for all of your time and help, I just wish it was more focused on what I was asking :/
Was This Post Helpful? -2
  • +
  • -

#6 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,593
  • Joined: 08-August 08

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 10:31 AM

You need to keep in mind that no one here cares what you're majoring in. When you post here, you're doing it because you want to get better at programming in PHP. If, through words or deeds, you prove to us that you aren't serious about doing that then we as a group will not be inclined to help.

You have a simple business decision to make: is it worth putting in the effort to learn to do this properly or should you hire some one who can?
Was This Post Helpful? 1
  • +
  • -

#7 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 10:44 AM

View PostCTphpnwb, on 30 April 2011 - 10:31 AM, said:

You need to keep in mind that no one here cares what you're majoring in. When you post here, you're doing it because you want to get better at programming in PHP. If, through words or deeds, you prove to us that you aren't serious about doing that then we as a group will not be inclined to help.

You have a simple business decision to make: is it worth putting in the effort to learn to do this properly or should you hire some one who can?


Except for the fact that my stepdad and I own a web design company and I am currently the webmaster behind it so it is indeed important for me to learn. I'm saying it is not extremely important about learning PHP from scratch this moment with my current time available. I just want some help that I will obviously retain because its important for the owner of a web design company to have a decent knowledge of all types of coding. You saying this is a simple business decision is correct for how I made it sound, but it in reality is definitely not what I am after. In the sense that I am making a website for my stepdads other company and we really need a form up and working 100% asap, that is where this predicament comes into affect. I would LOVE LOVE LOVE to know how everything works on the backend and one day I hope to learn a lot of it. I am saying may major because I am trying to get the point across that I am not going to school for web design as much as i would LOVE to because I honestly enjoy doing it so much, but that is why we own a web design company.. We plan on hiring people who know PHP and everything to do what we do not know what to do, ie. hire people like you guys on here because you know it like the back of your hand. I would love to have a background in web design html, php, javascript, everything OBVIOUSLY, but with my current time readily available, I would rather go the approach of getting it to work then figure out at a later time of how and why EXACTLY it is working. This is not because I am simply trying to quickly get the answer just to have it because I wont care about knowing how to do it in the future because that is completely false... I really want to know how to do all of this in the future and anything I learn here will be helpful, but I am simply saying that I cant spend all of my time going in depth with learning PHP from scratch when I just simply cannot at this time. What I am simply saying is that I DO want to learn how to do it and I WILL retain all information given and it is NOT just a simple business decision i am making at the current time although it sounds like this. I just need a form up and working 100% before I go and learn the basics because he is losing customers who leave the site simply because they put the security code in wrong and all of the info they typed up is now gone. I did not mean for you to take what I said before like that, but it is honestly not how it is.. I am young trying to learn and just with the current situation I am in, I cannot spend all of my time figuring out WHY and HOW.. After I get it working I will spend my free time learning why and how, but if I did that first then it wouldn't be good for potential lost customers.
Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,593
  • Joined: 08-August 08

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 11:23 AM

Quote

After I get it working I will spend my free time learning why and how, but if I did that first then it wouldn't be good for potential lost customers.

That is exactly the wrong way to go about it. It will take longer and you'll have a high probability of failure. What's more, anything you produce will be of mediocre quality at best. You'll also open your father's business up to additional liability because if a site you create is hacked it will be easy to show that the code was not up to professional standards.

Do it right, or hire some one to do it right.

This post has been edited by CTphpnwb: 30 April 2011 - 11:23 AM

Was This Post Helpful? 2
  • +
  • -

#9 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 11:28 AM

View PostCTphpnwb, on 30 April 2011 - 11:23 AM, said:

Quote

After I get it working I will spend my free time learning why and how, but if I did that first then it wouldn't be good for potential lost customers.

That is exactly the wrong way to go about it. It will take longer and you'll have a high probability of failure. What's more, anything you produce will be of mediocre quality at best. You'll also open your father's business up to additional liability because if a site you create is hacked it will be easy to show that the code was not up to professional standards.

Do it right, or hire some one to do it right.


I would obviously go back and edit it after learning the proper way if it is any different.. Can someone just help me figure out a type of "sticky form" or something.. I cant imagine it being very difficult, why can't someone just try to help me for a second. Okay, I want to learn PHP.. I want to learning how to build a proper form.. how do you go about making the info placed in sticky.. cant someone just give me an example of what you do by using $_GET or something that would work.. I am actually trying to learn how to do it, I wasn't planning on someone just revamping my entire form for me doing it all for me.. I just need help getting there...
Was This Post Helpful? 0
  • +
  • -

#10 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,593
  • Joined: 08-August 08

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 11:39 AM

Well first of all, you need to decide if you're going to use Javascript (not Java) or PHP to verify the information in the form. Javascript is processed on the browser without submitting to the server so the information won't change. PHP is processed on the server and it sends a new "page" back to the browser. It can insert the posted ($_POST or $_GET) values back into the form so that the user doesn't need to re-enter them.
Was This Post Helpful? 0
  • +
  • -

#11 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 11:55 AM

Okay, Thank You.. I honestly appreciate it.

I changed it to do this:

<?php session_start(); 
if(($_POST['check']) == $_SESSION['check']) { 
echo"<script>window.location = '../thankyou.php'</script>";
}else{ 
echo"<script>window.location = '../quote_error.php'</script>";  
die();      
}


So when you click "Send Request" on the page, it redirects you to another page which has that code at the top of it along with all of my data variables and the script that sends me the email.

Pretty much, I want to keep it so when you click the button, it is verified on serverside through javascript, which it currently is: http://www.contracto...y.com/quote.php

But I want the captcha to get verified on the separate page so bots dont go in an get the code. I have it set up with the code I posted above and it works fine, so pretty much if you get the security code right, it sends me the email and sends the use to the "thank you" page.. If you get it wrong, it sends you a new quote page entitled "quote_error.php" and it simply has a little error message telling them they put the wrong security code in and to try again. A) is it possible for the data the user put in to come back up on the new page by using the ($_POST or $_GET) commands?

If you fill out the form once and do the wrong info, you will see exactly how it is set up visually although I'm sure you understand from just seeing the code.

So can you help me with what I need to put on the new "quote_error.php" page in order to receive and put the info into the form (that the user put in) that is currently saved to the ($_POST) on the redirecting page?

Appreciate your help
Was This Post Helpful? 0
  • +
  • -

#12 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,593
  • Joined: 08-August 08

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 12:22 PM

Here's a simple example of using php to deal with a form.
<?php
$form = 'Enter name: <form method="post" action="test2.php"><input type="text" name="name" value="PHPVAL"><br><input type="submit" value="Submit"></form>';
if(isset($_POST['name'])) {
	$with = $_POST['name'];
} else {
	$with = '';
}
echo str_replace("PHPVAL",$with, $form);
?>

I'd normally have $form read from a file. See my tutorial on code separation.

As for the Javascript, you can get help with validation in the Javascript forum. Remember that whatever validation you do on the client side must be done again on the server, especially if the data will be going into a database.

This post has been edited by CTphpnwb: 30 April 2011 - 12:25 PM

Was This Post Helpful? 0
  • +
  • -

#13 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 12:32 PM

But I am not putting the info in a database or anything. All this form is meant to do in the end is send an E-mail with the info that was put in place. Would the coding you put there go on the new page (quote_error.php) right where the form starts and I just have to go through and list:

if(isset($_POST['name'])) {
$with = $_POST['name'];
if(isset($_POST['type'])) {
$with = $_POST['type'];
if(isset($_POST['address'])) {
$with = $_POST['address']; 


Etc. and that will place all of their info back into the form? Or am I mistaken? As for the javascript I have set up, everything works completely fine, all I have to figure out now is the PHP to replace the values into the form, I dont have to worry about the javascript as everything is working how I wanted it to.
Was This Post Helpful? 0
  • +
  • -

#14 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3034
  • Posts: 10,593
  • Joined: 08-August 08

Re: Captcha verify leads to form being erased. HELP

Posted 30 April 2011 - 04:09 PM

No, if you have multiple items in the form you'd need to loop through the posted values and assign them to $with as items in an array. You'd set up $replace as an array that contains the names of the posted keys.

Click here -->Read my tutorial!<-- Click here
Was This Post Helpful? 0
  • +
  • -

#15 flip4life  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 50
  • Joined: 29-April 11

Re: Captcha verify leads to form being erased. HELP

Posted 01 May 2011 - 01:02 AM

Hey, I took a look at your tutorial and I don't completely understand it.. I found a website here: http://www.tutorialc...p/sticky-forms/ and after following that and making some changes to the form, I was able to make it so when you refresh the page, the values the user put in retain.. I don't know how to make it so it retains the information after going to my quoteforumprocess.php and getting redirected either through "back" using javascript, or a redirect to quote_error.php. I am assuming that "sticky" forum is only meant for refreshing the page so it retains and not exactly meant for keeping the data there when going "back" or revisiting the page... I have been sitting here for hours just watching youtube videos and reading trying to understand $_POST and forms and I seem to understand it a tiny bit better now, but still pretty lost on it... I mean is it even possible to make it so when it redirects to my quote_error.php page that the information can be placed back in? For instance, you put information into quote.php, goes to my little quoteforumprocess.php script to verify the captcha and if wrong goes to quote_error.php which is exactly the same as my quote.php, except I added some text in there saying error with security code. Like is it even possible to do what I am thinking of? In that "sticky form" site, they mentioned to put
"<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"
which I am able to get it to save the data after pushing submit, but can I make it do that action then right after go to "quoteforumprocess.php" so when it comes back it will have saved the information put in place?

At this point I don't really care about getting this form done for the site, I am actually pretty interested in how all of this works. I am spending my free time trying to figure it out, but it is just so confusing to me. I feel like I am getting closer as I was able to make it so when you refresh the page info stays in, but I don't know if what I am doing is the completely wrong way or what is going on. I am getting kinda flustered, but at the same time, some satisfaction as I have gotten a step closer maybe :P I'm sorry I am not exactly that smart when it comes to this, but I do appreciate what you guys are doing for me [:
Was This Post Helpful? 0
  • +
  • -

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »