The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Troubble nesting several "pages" on the same page
Discuss Troubble nesting several "pages" on the same page in the PHP Development forum on Dev Shed. Troubble nesting several "pages" on the same page PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 26th, 2012, 03:10 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
|
Troubble nesting several "pages" on the same page
Hi,
As I cant pass the vars by post using headers, then I am trying to have all the information on the same page.
I have a page when they land on it a form is displayed to choose between 2 radiobuttons. With php I check if one if them is checked, if none is checked an error message is displayed.
If some of them is checked then another content will be displayed depending on button choosen.
This is the landing page in wich I have not included yet the content for the radiobuttons, only an echo to check that it works, and this works perfect:
PHP Code:
Original
- PHP Code |
|
|
|
<?php if ($_POST['enviar2']) { if (empty($bookingway)) { echo "<span class='style2'>Please choose instant booking or send enquirer and click on send again</span>"; }//if empty else{ if ($bookingway=="instant") }//if instant if ($bookingway=="enquirer") }//if enquirer }//else }//if enviar2 else {?> Text with form enviar2 here}
Then If they chekc button enquirer I want to display another form wich is a contact form. This form on a separat page works perfect, however when I try to add it inside the { } in this code: if ($bookingway=="enquirer"){ echo "enquirer"; }//if enquirer it does not send any email and dont give me the ok message, it just refresh the page and shows me the form for the landing content.
This is what I try to add into the if ($bookingway=="enquirer"){ echo "enquirer"; }//if enquirer:
PHP Code:
Original
- PHP Code |
|
|
|
<?php if ($_POST['enviar']) { if (! empty($_POST['name']) && ! empty($_POST['tel']) && ! empty($_POST['country']) && ! empty($_POST['email']) && ! empty($_POST['repeat_email']) && ! empty($_POST['repeat_email']) && $_POST['email'] == $_POST['repeat_email']) { $comments = str_replace("\\r\\n", " ", $comments); require("includes/class.phpmailer.php"); información mail etc...... echo "form has been sent"; if(!$mail->Send()) {echo "Message could not be sent, enter a valid e-mail. <p>"; echo "Mailer Error: " . $mail-> ErrorInfo; exit; } }//if not empty else { echo "<p> </p><p> </p><p> </p><p> </p><p class='red'>Something went wrong<br>You must fill in full name, telephone, country, valid email and repeat email to submit this form and email and repeat email must be equal.</p>"; } }//if enviar?> <table width="550px" align="center" border="0" cellpadding="0" cellspacing="0"> Here comes the form and ends: <p align="center"><input type="submit" name="enviar" value="Submit" id="submit" class="submit">
I been trying and starring to this....
Isn´t it possible to have a form inside another statement with a form, or is something else wrong?
Thanks,
Last edited by helenp : November 26th, 2012 at 04:43 AM.
|

November 26th, 2012, 03:14 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
|
Sorry, just dont get how to have it on several lines....
|

November 26th, 2012, 03:33 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Quote: | Originally Posted by helenp Sorry, just dont get how to have it on several lines.... |
Edit your post, select the code between the [php] tags, and paste directly into the text box. Don't use the popup dialog to enter code.
|

November 26th, 2012, 03:43 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by requinix Edit your post, select the code between the [php] tags, and paste directly into the text box. Don't use the popup dialog to enter code. |
Thanks, I done now but it should have the [php]tags....
I managed to do manually starting with [highlight="PHP"] and ending with /[highlight]
However don´t understand how to use the buttons.....guess I´m stupid.
Last edited by helenp : November 26th, 2012 at 04:44 AM.
|

November 26th, 2012, 04:36 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
It looks like one cant nest 2 if ($_POST
I done an easy form and I get the same result, instead of getting the ok from the echo, I get the echo for the landing content:
PHP Code:
Original
- PHP Code |
|
|
|
<?php if ($_POST['send2']) { if (empty($bookingway)) { echo "<span class='style2'>Please choose instant booking or send enquirer and click on send again</span>"; }//if empty else{ if ($bookingway=="instant"){ }//if instant if ($bookingway=="enquirer"){ if ($_POST['send']) ?><form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post" name="bookingways" id="bookingways"> <p align="center"><input class="boton" type="submit" name="send" value="Send"> </p> </form> <?php }//if enquirer }//else }//if send2 else {?> landing content here with form: name send2 }
Last edited by helenp : November 26th, 2012 at 05:05 AM.
|

November 26th, 2012, 04:57 AM
|
|
|
|
send2 and send are not the same variable you know (and you probably do, I think I misread the problem). And you should be using isset() on the $_POST variables.
__________________
I ♥ ManiacDan & requinix
This is a sig, and not necessarily a comment on the OP:
Please don't be a help vampire!
|

November 26th, 2012, 05:13 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by ptr2void send2 and send are not the same variable you know (and you probably do, I think I misread the problem). And you should be using isset() on the $_POST variables. |
Uups, sorry, no the name of the forms are ok, I just changed from spanish to english for easier understanding, fixed it now. There are 2 forms.
What do you measn with isset, something like:
if (isset($_POST['enviar2'])) {
?
This does not work either so I have it wrong
Thanks
|

November 26th, 2012, 07:48 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
|
Of course, how stupid I am, when the page refreshes, it goes to the else as it starting from the beginning.
If I put the if post form bebore the other form I get the echo OK correctly, however I get the else message below, and I dont want it at all, think I tried everything but ther must be a way.
This works but gives me the else from the startpage below the echo OK:
if (isset($_POST['enviar']))
{ echo "OK"; }
if (isset($_POST['enviar2'])) {
|

November 26th, 2012, 09:58 AM
|
|
Contributing User
|
|
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383
Time spent in forums: 6 Days 8 h 41 m 34 sec
Reputation Power: 0
|
|
|
It works now, changig the else to an elsif like this:
elseif(!isset($_POST['enviar'])) {
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|