PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 26th, 2012, 03:10 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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
  1. <?php   if ($_POST['enviar2'])
  2. { if (empty($bookingway))
  3.  { echo "<span class='style2'>Please choose instant booking or send enquirer and click on send again</span>";
  4. }//if empty
  5. else{ if ($bookingway=="instant")
  6. { echo "instant";
  7.  }//if instant if ($bookingway=="enquirer")
  8. { echo "enquirer";
  9.  }//if enquirer }//else
  10.  }//if enviar2
  11.  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
  1. <?php      if ($_POST['enviar']) { 
  2. 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'])
  3.  {  $comments = str_replace("\\r\\n", " ", $comments)require("includes/class.phpmailer.php");  información mail etc......  echo "form has been sent";
  4.  if(!$mail->Send())
  5.  {echo "Message could not be sent, enter a valid e-mail. <p>";     echo "Mailer Error: " . $mail->ErrorInfo;     exit;
  6. }
  7.  }//if not empty 
  8. else {
  9. echo "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</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>";
  10. }
  11.  }//if enviar?> 
  12. <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.

Reply With Quote
  #2  
Old November 26th, 2012, 03:14 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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....

Reply With Quote
  #3  
Old November 26th, 2012, 03:33 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 21 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
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.

Reply With Quote
  #4  
Old November 26th, 2012, 03:43 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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.

Reply With Quote
  #5  
Old November 26th, 2012, 04:36 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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
  1. <?php
  2.  if ($_POST['send2']) { 
  3. if (empty($bookingway)) {
  4. echo "<span class='style2'>Please choose instant booking or send enquirer and click on send again</span>";
  5. }//if empty
  6. else{
  7. if ($bookingway=="instant"){
  8.     echo "instant";
  9. }//if instant
  10. if ($bookingway=="enquirer"){
  11. echo "enquirer";
  12. if ($_POST['send'])
  13. {   echo "OK"; }
  14. ?><form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post" name="bookingways" id="bookingways">
  15. <p align="center"><input class="boton" type="submit" name="send" value="Send"> </p>
  16. </form>
  17. <?php }//if enquirer
  18. }//else
  19. }//if send2
  20. else {?>
  21. landing content here with form: name send2
  22. }

Last edited by helenp : November 26th, 2012 at 05:05 AM.

Reply With Quote
  #6  
Old November 26th, 2012, 04:57 AM
ptr2void ptr2void is offline
I haz teh codez!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,477 ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 7 h 25 m 53 sec
Reputation Power: 2194
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!

Reply With Quote
  #7  
Old November 26th, 2012, 05:13 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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

Reply With Quote
  #8  
Old November 26th, 2012, 07:48 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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'])) {

Reply With Quote
  #9  
Old November 26th, 2012, 09:58 AM
helenp helenp is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Marbella, Spain
Posts: 383 helenp Negative: is most likely a SPAMMER and a traitor to the cause. 
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'])) {

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Troubble nesting several "pages" on the same page

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap