co.ador Posted November 20, 2009 Share Posted November 20, 2009 page1.php <ol> <li> <input type="checkbox" name="example" value="delivery" /><span class="colo23">Delivery</span><br />" <input type="checkbox" name="example" value="eat-in" /><span class="checkboxes23">Eat-in</span><br /> <input type="checkbox" name="example" value="wifi" /><span class="checkboxes23">Wi-Fi</span><br /> <input type="checkbox" name="example" value="buffet" /><span class="checkboxes23">Buffet</span><br /> <input type="checkbox" name="example" value="tv" /><span class="checkboxes23">Tv</span><br /> <input type="checkbox" name="example" value="parking" /><span class="checkboxes23">Parking</span><br /> <input type="checkbox" name="example" value="catering" /><span class="checkboxes23">Catering</span><br /> <input type="checkbox" name="example" value="take-out" /><span class="checkboxes23">Take Out</span><br/> </li></ol> how can i transfer the values of the input tags from page1.php to page2.php trough the url to page 2 page2.php <?php $query3= "SELECT r.restaurantname, r.image, r.foodtype, z.city, z.state, FROM restaurant r LEFT OUTER JOIN zip_codes z ON r.zip = z.zip WHERE r.takeout, r.delivery, r.eatin, r.wifi, r.buffet, r.tv, r.parking, r.catering,r.zip = 1 "; $result3 = mysql_query($query3, $connection); while ($content3 = mysql_fetch_array($result3)) { echo "<div class=\"shoeinfo1\"> <img src=\"images/spacer.gif\" alt=\"spacer\" class=\"spacer2\" /> <h2 class=\"infohead\">". $content3['restaurantname'] . "</h2> <div class=\"pic\"><img class=\"line\" src= '". $content3['image'] ."' alt=\"picture\" width=\"100%\" height=\"100%\" /></div> </div> "; I have added the z.state in the Select statement in page.2 ï don't know if that is ok or is it enough with the z.city field? Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/ Share on other sites More sharing options...
mikesta707 Posted November 20, 2009 Share Posted November 20, 2009 if you want to send inputs, you need a form field, and you need to set the action of the form field to whatever page. for example <form action="page2.php" method="post" > form stuff <input type="submit" value="submit" /><!-- this is the submit button that submits the form --> Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962042 Share on other sites More sharing options...
cags Posted November 20, 2009 Share Posted November 20, 2009 <form action="page2.php" method="post"> <!-- your inputs here--> <input type="submit" name="submit" value="Click Me" /> </form> Then use $_POST['example'] to view the values. You actually said through the URL which would simply involve changing the method to "get" and then using $_GET, I just divined that's probably not what your intending. Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962043 Share on other sites More sharing options...
co.ador Posted November 20, 2009 Author Share Posted November 20, 2009 thank you guys <form class="abajo" action="page2.php" method="post"> <ol> <li> <input type="checkbox" name="example" value="delivery" /><span class="colo23">Delivery</span><br />" <input type="checkbox" name="example" value="eat-in" /><span class="checkboxes23">Eat-in</span><br /> <input type="checkbox" name="example" value="wifi" /><span class="checkboxes23">Wi-Fi</span><br /> <input type="checkbox" name="example" value="buffet" /><span class="checkboxes23">Buffet</span><br /> <input type="checkbox" name="example" value="tv" /><span class="checkboxes23">Tv</span><br /> <input type="checkbox" name="example" value="parking" /><span class="checkboxes23">Parking</span><br /> <input type="checkbox" name="example" value="catering" /><span class="checkboxes23">Catering</span><br /> <input type="checkbox" name="example" value="take-out" /><span class="checkboxes23">Take Out</span><br/> </li></ol> <input type="submit" value="submit" /> </form> Now the question to is with that set up above it's enough to sent the value=delivery, eat-in, wifi etc... throught the url don't the code need some kind of php code to sent it? Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962059 Share on other sites More sharing options...
cags Posted November 20, 2009 Share Posted November 20, 2009 No. Submitting the form via POST or GET has nothing todo with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962061 Share on other sites More sharing options...
co.ador Posted November 20, 2009 Author Share Posted November 20, 2009 the set up above is enough to retrive the data in page2.php Nice.... Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962064 Share on other sites More sharing options...
co.ador Posted November 20, 2009 Author Share Posted November 20, 2009 to retrive the value in page2.php from page1.php how is done? Do i have to the value of name, type, or value properties and use the Global GET in page2.php ? the submit bottom would have the similar characteristics <input name="Search" type="submit" value="Search" /> so in page2.php will have to global get the name, type or value property? for instance <?php if(isset($_GET['value']) { $query3= "SELECT r.restaurantname, r.image, r.foodtype, z.city, z.state, FROM restaurant r LEFT OUTER JOIN zip_codes z ON r.zip = z.zip WHERE r.takeout, r.delivery, r.eatin, r.wifi, r.buffet, r.tv, r.parking, r.catering,r.zip = 1 "; $result3 = mysql_query($query3, $connection); while ($content3 = mysql_fetch_array($result3)) { echo "<div class=\"shoeinfo1\"> <img src=\"images/spacer.gif\" alt=\"spacer\" class=\"spacer2\" /> <h2 class=\"infohead\">". $content3['restaurantname'] . "</h2> <div class=\"pic\"><img class=\"line\" src= '". $content3['image'] ."' alt=\"picture\" width=\"100%\" height=\"100%\" /></div> </div> "; }?> is that ok.. it is something similar like that, I want to display all the stores of a x state, zip, etc that has the values checked by the user throught the checkboxes Thank you Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962079 Share on other sites More sharing options...
cags Posted November 20, 2009 Share Posted November 20, 2009 $_GET and $_POST are superglobal arrays. They will contain all of the elements from your form in an associative array. Since in your example all your inputs have the same name, that would make $_POST['example'] an array that would contain the value of any checkbox that was checked (unchecked boxes aren't submitted). So $_POST['example'][0] would be the first checked box, $_POST['example'][1] the second and so forth. Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962082 Share on other sites More sharing options...
co.ador Posted November 20, 2009 Author Share Posted November 20, 2009 if you notice in the example above I have put <?php] if(isset($_GET['value'])?> so instead of 'value' the name of the input would be 'example' because is the name of the input that goes inside the brackets. I thought it was the value that need to go in there anyways.. then the final draft would be <?php if(isset($_GET['example']) { $query3= "SELECT r.restaurantname, r.image, r.foodtype, z.city, z.state, FROM restaurant r LEFT OUTER JOIN zip_codes z ON r.zip = z.zip WHERE r.takeout, r.delivery, r.eatin, r.wifi, r.buffet, r.tv, r.parking, r.catering,r.zip = 1 "; $result3 = mysql_query($query3, $connection); while ($content3 = mysql_fetch_array($result3)) { echo "<div class=\"shoeinfo1\"> <img src=\"images/spacer.gif\" alt=\"spacer\" class=\"spacer2\" /> <h2 class=\"infohead\">". $content3['restaurantname'] . "</h2> <div class=\"pic\"><img class=\"line\" src= '". $content3['image'] ."' alt=\"picture\" width=\"100%\" height=\"100%\" /></div> </div> "; }?> then the Select query statament will get in charge of picking up which checkboxes has been pickup right? Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962083 Share on other sites More sharing options...
co.ador Posted November 20, 2009 Author Share Posted November 20, 2009 http://nyhungry/page2.php?name=&email=&state=&food-type=spanish&Search=Search&example=eat-in&example=tv instead of $name= $_GET['name']; $email= $_GET['email']; etc... That would be smart to do it with a php foreach loop? as below <?php <?php $myGETS = array(); FOREACH ($_POST as $key => $value) : $myGETS[] = $key; ENDFOREACH; ?> ?> Then use the variables $myGETS to populates the variables values inside page2.php? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962093 Share on other sites More sharing options...
co.ador Posted November 20, 2009 Author Share Posted November 20, 2009 guys i have the following url and the following variables and its values http://localhost/store/page2.php?name=&zipcode=&state=&foodtype=spanish&submit=Search&example=delivery&example=buffet page2.php <?php $restaurantname = $_GET['name']; $zipcode = $_GET['zipcode']; $state = $_GET['state']; $foodtype = $_GET['foodtype']; $checkboxes = $_GET['example']; ?> or do i have to call in page2.php each of the examples variables or it's fine as it is? <?php $checkboxes = $ _GET[' example'] ?> Quote Link to comment https://forums.phpfreaks.com/topic/182311-how-can-i-send-data-from-input-tags-to-pagephp/#findComment-962100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.