jalea148 Posted June 28, 2007 Share Posted June 28, 2007 I have 2 forms [say they are called form1 and form2]; each has its own Post action. In both forms , there is a field called ‘name’. After the post of form1 I capture fields in the second page from the first page with statements like $name=$_POST['name']; How do I get form2.name.value set to $name? I tried the following, but it treats $name as a literal string. <input type="text" name="name" size="20" value=$name> Quote Link to comment Share on other sites More sharing options...
corbin Posted June 28, 2007 Share Posted June 28, 2007 <?php echo '<input type="blah blah" blah blah value="'$name'" /> Or in HTML: <input blah blah blah value="<?php echo $name; ?>" /> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 28, 2007 Share Posted June 28, 2007 Are you in out of your PHP tags? Try this: <input type="text" name="name" size="20" value="<?php echo $name; ?>"> Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 :-\ The 2 replies work beautifully with my simple test form, but all I get is a null string in my real form. Here's the snippit at the top of my code: body { background-color: #670065; } <?php $First = $_POST['custom First']; $Last = $_POST['custom Last']; $Address = $_POST['custom Address1']; $City = $_POST['custom City']; $State = $_POST['custom State']; $Zip = $_POST['custom Zipcode']; $Phone = $_POST['custom Phone']; $Email = $_POST['from']; ?> .................... then in the form <tr><td colspan="2"><div align="right" class="style12"><p>First</p> </div></td> <td> <p><input name="First" type="text" class="req" id="First" tabindex="15" size="50" value="<?php echo $First; ?>" /> </p></td> </tr> When the source is viewed, it shows value="". Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Are you sure that the variable $First has a value? Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 How do I test for this - I put in my name before the submit on the original form. Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 I'm fairly sure the field is not null. Earlier I had a different action URL. The data came back from the ther site and was complete. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Change this: $First = $_POST['custom First']; To this: $First = $_POST['First']; Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 removing 'custom ' didn't help. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Can you post more code than that? The inputs name is "First", not "Custom First". I'm not sure where your getting the "custom" from. Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 Here is a snippit [the full code is about 2k lines]. The echo statements should the passed data is null here. body { background-color: #670065; } <?php $First = $_POST['First']; $Last = $_POST['Last']; $Address = $_POST['Address1']; $City = $_POST['City']; $State = $_POST['State']; $Zip = $_POST['Zipcode']; $Phone = $_POST['Phone']; $Email = $_POST['from']; ?> <?php echo $First.' bases<br>'; echo $Last.' stems<br>'; echo $Email.' tops<br>'; ?> Here's the result of the echos: 'bases<br> stems<br> tops<br>' Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Can you post the form you are using to submit and get those values? Also, are you using an if statement to check if the form was submitted? Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 No, I don't have an If Here's the submit form: <td valign="top"><form id="form_weber" name="form_weber" method="post" action="http://www.aweber.com/scripts/addlead.pl"> <p> <input type="hidden" name="meta_web_form_id" value="724199692"> <input type="hidden" name="meta_split_id" value=""> <input type="hidden" name="unit" value="quote_form"> <input type="hidden" name="redirect" value="http://www.ehealthinsurancesource.com/Quote_FORM.php"> <input type="hidden" name="meta_redirect_onlist" value=""> <input type="hidden" name="meta_adtracking" value=""> <input type="hidden" name="meta_message" value="1"> <input type="hidden" name="meta_required" value="First,Last,Address1,City,State,Zipcode,Phone,from"> <input type="hidden" name="meta_forward_vars" value="0"> </p> <table width="346" border="2"> <tr> <td width="150"><div align="left">First Name </div></td> <td><label> <input name="First" type="text" id="First" /> </label></td> </tr> <tr> <td><div align="left">Last Name </div></td> <td><label> <input name="Last" type="text" id="Last" /> </label></td> </tr> <tr> <td><div align="left">Address</div></td> <td><input name="Address1" type="text" id="Address1" /></td> </tr> <tr> <td><div align="left">City</div></td> <td><input name="City" type="text" id="City" /></td> </tr> <tr> <td><div align="left">State</div></td> <td><input name="State" type="text" id="State" /></td> </tr> <tr> <td><div align="left">Zip</div></td> <td><input name="Zipcode" type="text" id="Zipcode" /></td> </tr> <tr> <td><div align="left">Phone</div></td> <td><input name="Phone" type="text" id="Phone" /></td> </tr> <tr> <td><div align="left">Email</div></td> <td><input type="text" name="from" value="" size="20"></td> </tr><tr> </tr> </table> <p> <label> <input name="SubmitWeber" type="submit" id="SubmitWeber" value="Press for Quote" /> </label> </p> </form> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Okay, on the top of this page: http://www.aweber.com/scripts/addlead.pl Put the following code and see what you get. <?php if ($_POST['SubmitWeber']){ $first = $_POST['First']; $last = $_POST['Last']; echo '<b>First</b>: '.$first.'<br>'; echo '<b>Last</b>: '.$last.'<br>'; } ?> Copy and paste what you see. Make sure you actually fill in those two fields with values. Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 Nothing happens after I change the top of the submit for to <?php if ($_POST['SubmitWeber']){ $first = $_POST['First']; $last = $_POST['Last']; echo '<b>First</b>: '.$first.'<br>'; echo '<b>Last</b>: '.$last.'<br>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> Do I need to change its name from xyz.htm to xyz.php? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Ah, I wasn't aware this wasn't a PHP file. So yes, your going to have to change it to a .php extension. And the PHP goes in between the body tags Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 Your wanting the form to be submitted to this URL, correct? http://www.aweber.com/scripts/addlead.pl That is where you have the form action pointing to. What page did you have your previous code on? The $_POST information is sent to the page where the form action is directed at. Quote Link to comment Share on other sites More sharing options...
jalea148 Posted June 29, 2007 Author Share Posted June 29, 2007 Thank you. So, do you recommend using Session Variables to pass this data to the Redirected form? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 29, 2007 Share Posted June 29, 2007 If you are redirecting them, then yes...you will have to store the information in sessions, otherwise the POST data would be lost in the redirection. If they submit the form, and it takes them straight to the page where you set the form action, and they are not redirected from there...then sessions shouldn't be necessary. You can then just simply echo them to the screen. 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.