Jump to content

Recommended Posts

Okay... I got a problem with html and php "talking" to each other.

This is for a school assignment, and I've decided to go that little bit further...

 

The idea is that there is 3 types of seating at a rock concert, and after selecting there decision, it will then re-direct to a new html page.

 

The query, here:

http://i44.tinypic.com/e9huli.jpg

 

Okay, so, if the viewer selects blue, then submit, show an image of the blue type ticket that I am going to make later (On a different page, placed on the site template).

 

Simple talk:

Blue goes to "blue.html"

Pink goes to "pink.html"

Green goes to "green.html"

After it is selected, and submit is pressed.

 

The form in html:

<form id="form1" name="form1" method="post" action="">
  <label></label>
    <p>
                                  <label></label>
                                  <span class="style6">Select Your Seating: </span></p>
    <p>
      <label>
      <input name="radiobutton" type="radio" value="blue" />
      Blue Seating</label><br />
      <label>
      <input name="radiobutton" type="radio" value="pink" />
      Pink Seating</label><br />
      <label>
      <input name="radiobutton" type="radio" value="green" />
      Green Seating</label>
    </p>
    <p>All seating includes around the clock access to the moshpit. </p>
    <p>
      <label>
      <input type="submit" name="submit" value="Submit" id="submit" />
      </label>
    </p>
</form>

 

 

I don't know, and I can't find out how to get the php to do whatever it has too.

 

If you guide me on the right track, that'd be great thanks.

 

~Party Animal

Link to comment
https://forums.phpfreaks.com/topic/147276-form-query/
Share on other sites

It goes lke this

1) assume the form above is named help.php

2) that the results form is named helpresults.php

 

3) in help.php post to helpresults.php

4) in helpresults.php before anything

<?

//we first test wether anything was posted

if (!count($_POST['radiobutton'])  ) {

header("Location: help.php");  //Relocate back to main page

}

//echo 'radiobutton'.count($_POST['radiobutton']).'<br>';

//print_r ($_POST);

?>

5) Somewhere in the body of results page

<?

 

if ($_POST['radiobutton']='Green')  {

//generate code using javascript to display images. Note that ../images is a directory

echo "<img src=\""."../images/myimage.jpg\"></a></td>";

} elseif ($_POST['radiobutton']='Blue') {

//generate code using javascript to display images

} else {

 

}

?>

 

U now  know  why the Maasai kill lions

 

Link to comment
https://forums.phpfreaks.com/topic/147276-form-query/#findComment-773126
Share on other sites

if (isset($_POST['submit']))
{
     if(isset($_POST['radiobutton'])) {
          $page = $_POST['radiobutton'] . ".php";
          header("Location: $page");
     }
} else {
   echo "you did not select a seating section!";
}
?>




</pre>
<form id="form1" name="form1" method="POST" action="<?php%20echo%20%24_SERVER%5B'PHP_SELF'%5D;%20?>">
  
    

     
      Select Your Seating: 
    

      
      
      Blue Seating

      
      
      Pink Seating

      
      
      Green Seating
    
    
All seating includes around the clock access to the moshpit. 
    

      
      
      
    
</form>
<br><b

Link to comment
https://forums.phpfreaks.com/topic/147276-form-query/#findComment-775005
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.