submit form, and then carry a variable to a new page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

submit form, and then carry a variable to a new page

Post by inosent1 »

hi

i have a simple mission: the user submits a mailer form, with data in fields to be sent, then i want there to be a new page displayed but the catch is i want the data from one of the fields of the form mailer to be put inside of a text box on the new page

is this possible? is there a code example i can see?

thanks
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: submit form, and then carry a variable to a new page

Post by daedalus__ »

inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

Re: submit form, and then carry a variable to a new page

Post by inosent1 »

thanks, but i did not readily see the code i was looking for there
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: submit form, and then carry a variable to a new page

Post by daedalus__ »

the first result of the google search.

if that didnt help then i must not understand the question.

you wanted to take data posted to the page by a form and output it to the screen right?
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

Re: submit form, and then carry a variable to a new page

Post by inosent1 »

yes i must not have been very clear

page 1 has two fields

Name
Number

Submit

submit sends to my email

then i want a new page to show up with another form, which has a form field called 'name' and i want the new page to show this form with this field and have the name filled in, not just displayed, but a field filled in

i will eventually figure it out by going through 100 tutorials, but if there is some code readily available that can do this that would be grreat

thanks
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: submit form, and then carry a variable to a new page

Post by daedalus__ »

well you dont really need to navigate to a new page

put the new form on the page that sends the email

then to fill in the form you just set the value attribute of the input element.
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

Re: submit form, and then carry a variable to a new page

Post by inosent1 »

for what i am trying to do a new page is necessary

in some code i have there is this

Code: Select all

 
<?php
                      
                      if ($emessage==1)
                      {
                      echo "<span class='style2'><b>Thanks, the data has been sent!</b></span>";
                      }
                      ?>
 
 
 
what this does is after the form is submitted displays on the same page the text shown.

but i want to fill in a field in a specific form, let's say the form is called 'form2' and the field name is 'name'

instead of the code above, assuming 'form2' exists on the same page, what code do i use so after i submit the form the awaiting field gets filled in?

thanks
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: submit form, and then carry a variable to a new page

Post by daedalus__ »

*sigh*

you dont need a new page just a conditional statement that sets the state of the page. form1, form2, or success or whatever

if you want to carry the variable over to the new page you are going to have to post using a hidden form or pass it using a query string.

so you display the welcome page welcome.php then have it redirect or link to the mail form page

thanks for the mail! click <a href="mail.php?name=daedalus">here</a> to return!

then on mail.php you access the name variable through the $_GET super global

<input type="text" value="<?php $_GET['name'] ?>

http://us3.php.net/manual/en/tutorial.forms.php
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

Re: submit form, and then carry a variable to a new page

Post by inosent1 »

unless i have a working example i'll never figure it out. thanks for ur ideas
Post Reply