Jump to content

[SOLVED] 2 forms


jalea148

Recommended Posts

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>

 

Link to comment
Share on other sites

:-\ 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="".

 

 

Link to comment
Share on other sites

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>'

 

Link to comment
Share on other sites

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>

       

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.