PHP - Site Won't Submit Multiple Variables
I have a webpage that I am working on that is now in construction mode. The url is: https://localbizseek.com/lbs/index6 The problem is that I want to it to be able to search 2 at the same time in the phpmyadmin database table which is named "places". I also want to be able to get to search all 9 cities for that area. There are a total of 36,000+ cities in the database. However, I want it to be able to search just 2 or 9 specific cities of those cities. Each city has a city_id which is an integer assigned to it in the database Right now it will search only 1 city at a time or it will search every city in the database if I assign the search variable as "" or "0". I don't know what to do on this page to solve it and on the related processing page. Here is the code on the webpage: <form id="main-search-form" method="GET" action="<?= $baseurl; ?>/_searchresults.php" role="search"> <select id="query-input" name="city_id" style="width:28.8%" style="height:69px" required> <option value="">Select Area</option> <option value="3;1">Ches & VB</option> <option value="3">Chesapeake , VA</option> <option value="9">Hampton , VA</option> <option value="10">Newport News , VA</option> <option value="2">Norfolk , VA</option> <option value="12">Poquoson , VA</option> <option value="4">Portsmouth , VA</option> <option value="5">Suffolk , VA</option> <option value="1">Virginia Beach , VA</option> <option value="11">Williamsburg , VA</option> <option value="0">All Active US Cities</option> </select> </form>
You will notice that I have tried "3;1" up under the Ches & VB Select Option but that doesn't work because it will not work that way. I can have it as "3 1" but then it just displays 1 which is VB's information. I've tried everything possible and it won't search both variables. It only will search one. <form id="main-search-form" method="GET" action="<?= $baseurl; ?>/_searchresults.php" role="search"> <select id="query-input" name="city_id" style="width:28.8%" style="height:69px" required> <option value="">Select Area</option> <option value="3,1">Ches & VB</option> <option value="3">Chesapeake , VA</option> <option value="9">Hampton , VA</option> <option value="10">Newport News , VA</option> <option value="2">Norfolk , VA</option> <option value="12">Poquoson , VA</option> <option value="4">Portsmouth , VA</option> <option value="5">Suffolk , VA</option> <option value="1">Virginia Beach , VA</option> <option value="11">Williamsburg , VA</option> <option value="0">All Active US Cities</option> </select>
Here is the final page of code which I'm not sure if this one needs changing but just in case here it is: <!DOCTYPE html> <!--[if IE 9]><html class="lt-ie10" lang="<?= $html_lang; ?>"> <![endif]--> <html class="no-js" lang="<?= $html_lang; ?>"> <head> <title><?= $txt_html_title; ?> - <?= $site_name; ?></title> <meta name="description" content="<?= $txt_meta_desc; ?>" /> <meta name="robots" content="noindex"> <?php require_once('_html_head.php'); ?> </head> <body class="tpl-searchresults"> <?php require_once('_header.php'); ?> <h1><?= $txt_main_title; ?></h1> <div class="full-block"> <div class="content-col"> <div class="list-items"> <?php /* -------------------------------------------------- BEGIN SHOW LIST -------------------------------------------------- */ if($total_rows > 0) { $count = ($page - 1) * $limit; $results_arr = array(); foreach($list_items as $k => $v) { $count++; $place_id = $v['place_id']; $place_name = $v['place_name']; $place_slug = $v['place_slug']; $address = $v['address']; $cross_street = $v['cross_street']; $place_city_name = $v['place_city_name']; $place_city_slug = $v['place_city_slug']; $place_state_abbr = $v['place_state_abbr']; $postal_code = $v['postal_code']; $area_code = $v['area_code']; $phone = $v['phone']; $phone = preg_replace("/[^0-9]/", "", $phone); $phone = substr($phone, 0, 3) . '-' . substr($phone, 3); $lat = $v['lat']; $lng = $v['lng']; $cat_icon = $v['cat_icon']; $photo_url = $v['photo_url']; $rating = $v['rating']; $description = $v['description']; $results_arr[] = array( 'ad_id' => $place_id, 'ad_lat' => $lat, 'ad_lng' => $lng, 'ad_title' => $place_name, 'count' => $count, 'cat_icon' => $cat_icon); $places_names_arr[] = $place_name; ?> <div class="item" data-ad_id="<?= $place_id; ?>"> <div class="item-pic" id="<?= $place_id; ?>"> <img src="<?= $photo_url; ?>" /> </div><!-- .item-pic --> <div class="item-description"> <div class="item-title-row"> <div class="item-counter"><div class="item-counter-inner"><?= $count; ?></div></div> <h2><a href="<?= $baseurl; ?>/<?= $place_city_slug; ?>/place/<?= $place_id; ?>/<?= $place_slug; ?>" title="<?= $place_name; ?>"><?= $place_name; ?></a></h2> </div> <div class="item-ratings-wrapper"> <div class="item-rating" data-rating="<?= $rating; ?>"> <!-- raty plugin placeholder --> </div> <div class="item-ratings-count"> <?php // echo $count_rating; ?> <?php // echo ($count_rating == 1 ? 'review' : 'reviews'); ?> </div> <div class="clear"></div> </div><!-- .item-ratings-wrapper --> <div class="item-info"> <div class="item-addr"> <strong> <?= (!empty($address)) ? $address : ''; ?> </strong> <?= (!empty($cross_street)) ? "($cross_street)" : ''; ?> <br> <strong> <?= (!empty($place_city_name)) ? "$place_city_name," : ''; ?> <?= (!empty($place_state_abbr)) ? " $place_state_abbr " : ''; ?> <?= (!empty($postal_code)) ? $postal_code : ''; ?> </strong> </div> <div class="item-phone"> <?= (!empty($phone)) ? '<i class="fa fa-phone-square"></i>' : ''; ?> <?= (!empty($area_code)) ? $area_code : ''; ?> <?= (!empty($phone)) ? $phone : ''; ?> </div> </div><!-- .item-info --> <?php echo (!empty($tip_text)) ? $tip_text : ''; ?> </div><!-- .item-description --> <div class="clear"></div> </div><!-- .item --> <?php } // end foreach($response as $k => $v) } // end if($total_rows > 0) else { // else no results found ?> <div class="empty-cat-template"> <p><?= $txt_empty_results; ?></p> </div> <?php } ?> </div><!-- .list-items --> <?php /* -------------------------------------------------- BEGIN PAGER -------------------------------------------------- */ ?> <div id="pager"> <ul class="pagination"> <?php if(!empty($pager) && $pager->getTotalPages() > 1) { $curPage = $page; $startPage = ($curPage < 5)? 1 : $curPage - 4; $endPage = 8 + $startPage; $endPage = ($pager->getTotalPages() < $endPage) ? $pager->getTotalPages() : $endPage; $diff = $startPage - $endPage + 8; $startPage -= ($startPage - $diff > 0) ? $diff : 0; $startPage = ($startPage == 1) ? 2 : $startPage; $endPage = ($endPage == $pager->getTotalPages()) ? $endPage - 1 : $endPage; if($total_rows > 0) { $page_url = "$baseurl/_searchresults.php?city_id=$query_city_id&query=$query_query&page="; if ($curPage > 1) { ?> <li><a href="<?= $page_url; ?>1">Page 1</a></li> <?php } if ($curPage > 6) { ?> <li><span>...</span></li> <?php } if ($curPage == 1) { ?> <li class="active"><span>Page 1</span></li> <?php } for($i = $startPage; $i <= $endPage; $i++) { if($i == $page) { ?> <li class="active"><span><?= $i; ?></span></li> <?php } else { ?> <li><a href="<?php echo $page_url, $i; ?>"><?= $i; ?></a></li> <?php } } if($curPage + 5 < $pager->getTotalPages()) { ?> <li><span>...</span></li> <?php } if($pager->getTotalPages() > 5) { $last_page_txt = "Last Page"; } $last_page_txt = ($pager->getTotalPages() > 5) ? "Last Page" : $pager->getTotalPages(); if($curPage == $pager->getTotalPages()) { ?> <li class="active"><span><?= $last_page_txt; ?></span></li> <?php } else { ?> <li><a href="<?php echo $page_url, $pager->getTotalPages(); ?>"><?= $last_page_txt; ?></a></li> <?php } } // end if($total_rows > 0) } // end if(isset($pager) && $pager->getTotalPages() > 1) if(isset($pager) && $pager->getTotalPages() == 1) { ?> <?php } ?> </ul> </div><!-- #pager --> </div><!-- .content-col --> <div class="sidebar"><div class="clear"></div> <?php if($total_rows > 0) { ?> <div class="clear"></div> <div class="map-wrapper" id="sticker"> <div id="map-canvas" style="width:100%; height:100%"></div> </div> <?php } ?> </div> <div class="clear"></div> <!-- #sidebar --> <div class="clear"></div> </div><!-- .content-full --> <?php require_once('_footer.php'); ?> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<?= $google_key; ?>"></script> <script type="text/javascript"> // place markers var results_obj = <?php echo json_encode($results_arr); ?>; var infowindow; var map; function initialize() { markers = {}; infoboxcontents = {}; // set map options var mapOptions = { zoom: 1 }; // instantiate map var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var bounds = new google.maps.LatLngBounds(); var infowindow = new google.maps.InfoWindow(); // $results_arr[] = array("ad_id" => $place_id, "ad_lat" => $ad_lat, "ad_lng" => $ad_lng, "ad_title" => $ad_title, "count" => $count); // set markers for (var k in results_obj) { var p = results_obj[k]; var latlng = new google.maps.LatLng(p.ad_lat, p.ad_lng); bounds.extend(latlng); var marker_icon = '<?= $baseurl; ?>/imgs/marker1.png'; // place markers var marker = new google.maps.Marker({ position: latlng, map: map, animation: google.maps.Animation.DROP, title: p.ad_title, //icon: marker_icon }); markers[p.ad_id] = marker; infoboxcontents[p.ad_id] = p.ad_title; // click event on markers to show infowindow google.maps.event.addListener(marker, 'click', function() { infowindow.setContent(this.title); infowindow.open(map, this); }); } // end for (var k in results_obj) map.fitBounds(bounds); $(".list-items .item").mouseover(function() { marker = markers[this.getAttribute("data-ad_id")]; // mycontent = infoboxcontents[this.getAttribute("data-ad_id")]; mycontent = '<div class="scrollFix">' + infoboxcontents[this.getAttribute("data-ad_id")] + '</div>'; // console.log(mycontent); infowindow.setContent(mycontent); // infowindow.setOptions({maxWidth:300}); infowindow.open(map, marker); marker.setZIndex(10000); }); // end mouseover } // end initialize() google.maps.event.addDomListener(window, 'load', initialize); </script> <script type="text/javascript"> $.fn.raty.defaults.path = '<?= $baseurl; ?>/templates/lib/raty/images'; $('.item-rating').raty({ readOnly: true, score: function(){ return this.getAttribute('data-rating'); } }); </script> <script> $(document).ready(function(){ $("#sidebar").sticky({topSpacing:0}); }); </script> <script> $(document).ready(function(){ $("#sticker").sticky({topSpacing: 24}); }); </script> <script type="text/javascript"> function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes.split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } $(document).ready(function() { var loc = '<?= e($_GET['loc']); ?>'; var query = '<?= e($_GET['query']); ?>'; if(loc !== '') { $("#city-input").val(loc); } if(query !== '') { $("#query-input").val(query); } }); </script> </body> </html> Edited April 13, 2019 by requinix please use the Code <> button when posting code. Similar TutorialsSay I have an "Entries" table. I want to submit same multiple entries using a form submission. And If I have other queries submitted in the same form, I want those quarries to be submitted only once. Is that possible to do? Here's my code. if(isset($_POST['submit'])) { $entries = 10; $id = 55; $name = 'Smith'; $insert = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); $insert->bindParam(':id', $id); $insert->bindParam(':name', $name); $result_insert = $insert->execute(); if($result_insert == false) { echo 'Fail'; } else { echo 'Success'; } } ?> <form action="" method="post"> <input type="submit" name="submit" value="SUBMIT" /> </form> Edited January 13, 2019 by imgrooot I have an url, for example: Quote something.com/page.php?value=something Code: [Select] $test = mysql_real_escape_string($_GET['value']); I require this variable $test after the submit button is pressed, but the url does not keep it anymore. (../page.php). Is there a way i could keep it after the submit? Code: [Select] if (isset($_POST["Submit"])) { operating with $test... } form... So I'm making an ordering form for pizza, and it works fine and im using two separate pages: 1- display the form where the user can select the pizza, and 2-display the order and the price, and user can go back and edit the problem im having is when i got back from the 2nd page to the 1st page, to edit the data, I want the variables to stay the same. For example, if the user selected a medium cheese pizza, i want the values of cheese and pizza to still be there, so the user doesnt have to fill the entire form out again. ive done this before, but now when i try it doesn''t work and Ive tried everything. Thanks in advance If the code is needed, I'll post it here Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Title of the document</title> <meta name="description" content="Type a Short Description Here" /> <meta name="keywords" content="type, keywords, here" /> <meta name="author" content="Your Name" /> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> <body> <?php print_r ($_REQUEST) ; if(isset($_POST['ORDER'])) { $ORDER = $_POST['ORDER']; } if(isset($_POST['PTYPE'])) { $PTYPE = $_POST['PTYPE']; } if(isset($_POST['DTYPE'])) { $DTYPE = $_POST['DTYPE']; } if(isset($_POST['PSIZE'])) { $PSIZE = $_POST['PSIZE']; } if(isset($_POST['DSIZE'])) { $DSIZE = $_POST['DSIZE']; } if(isset($_POST['PTYPE2'])) { $PTYPE2 = $_POST['PTYPE2']; } if(isset($_POST['DTYPE2'])) { $DTYPE2 = $_POST['DTYPE2']; } if(isset($_POST['PSIZE2'])) { $PSIZE2 = $_POST['PSIZE2']; } if(isset($_POST['DSIZE2'])) { $DSIZE2 = $_POST['DSIZE2']; } if(isset($_POST['PTYPE3'])) { $PTYPE3 = $_POST['PTYPE3']; } if(isset($_POST['DTYPE3'])) { $DTYPE3 = $_POST['DTYPE3']; } if(isset($_POST['PSIZE3'])) { $PSIZE3 = $_POST['PSIZE3']; } if(isset($_POST['DSIZE3'])) { $DSIZE3 = $_POST['DSIZE3']; } echo "Order Type: <br/> \n"; echo"<form method='post' action='project2.php'>"; }if ($ORDER=='delivery') { $DEL='checked' ; }elseif ($ORDER=='takeout') { $TAKE='checked'; }elseif ($ORDER=='eatin') { $EAT='checked'; } echo"Delivery <input type='radio' name='ORDER' value='delivery' $DEL> \n"; echo"Take Out <input type='radio' name='ORDER' value='takeout' $TAKE> \n"; echo"Eat in <input type='radio' name='ORDER' value='eatin' $EAT> \n"; if ($PTYPE==='no pizza') { $NOPIZZA='selected' ; }elseif ($PTYPE=='cheese') { $CHEESE='selected' ; }elseif ($PTYPE=='pepporoni') { $PEPPORONI='selected' ; }elseif ($PTYPE=='veggie') { $VEGGIE='selected' ; }elseif ($PTYPE=='meat lovers') { $MEAT='selected' ; } echo $CHEESE ; echo"<br/>Pizza: <select name='PTYPE'>\n"; echo"<option></option>"; echo"<option $NOPIZZA>no pizza</option>"; echo"<option $CHEESE>cheese</option>"; echo"<option $PEPPORONI>pepporoni</option>"; echo"<option $VEGGIE>veggie</option>"; echo"<option $MEAT>meat lovers</option>"; echo"</select> "; $SMALL='selected' ; if (isset ($_POST['PSIZE']) && ($PSIZE=='Small')) { $SMALL='selected' ; }elseif (isset ($_POST['PSIZE']) && ($PSIZE=='Medium')) { $MEDIUM='selected' ; }elseif (isset ($_POST['PSIZE']) && ($PSIZE=='Large')) { $LARGE='selected' ; } echo "$SMALL"; echo" Pizza size: <select name='PSIZE'>\n"; echo"<option></option>"; echo"<option $SMALL>Small</option>"; echo"<option $MEDIUM>Medium</option>"; echo"<option $LARGE>Large</option>"; echo"</select>"; echo"<br/>Pizza2: <select name='PTYPE2'>\n"; echo"<option></option>"; echo"<option >no pizza</option>"; echo"<option >cheese</option>"; echo"<option >pepporoni</option>"; echo"<option >veggie</option>"; echo"<option >meat lovers</option>"; echo"</select> "; echo" Pizza size2: <select name='PSIZE2'>\n"; echo"<option></option>"; echo"<option>Small</option>"; echo"<option>Medium</option>"; echo"<option>Large</option>"; echo"</select>"; echo"<br/>Pizza3: <select name='PTYPE3'>\n"; echo"<option></option>"; echo"<option >no pizza</option>"; echo"<option >cheese</option>"; echo"<option >pepporoni</option>"; echo"<option >veggie</option>"; echo"<option >meat lovers</option>"; echo"</select> "; echo"Pizza size3: <select name='PSIZE3'>\n"; echo"<option></option>"; echo"<option>Small</option>"; echo"<option>Medium</option>"; echo"<option>Large</option>"; echo"</select>"; echo"</br> <br/>What drink would you like? <select name='DTYPE'>"; echo"<option></option>"; echo"<option>No drink</option>"; echo"<option>Bottled Pepsi</option>"; echo"<option>Bottled Fanta</option>"; echo"<option>Bottled Sprite</option>"; echo"<option>Bottled RootBeer</option>"; echo"</select>"; echo"Drink size: <select name='DSIZE'>"; echo"<option></option>"; echo"<option>.5 liter</option>"; echo"<option>1 liter</option>"; echo"<option>2 liter</option>"; echo"</select>"; echo"</br> <br/>What second drink would you like? <select name='DTYPE2'>"; echo"<option></option>"; echo"<option>No drink</option>"; echo"<option>Bottled Pepsi</option>"; echo"<option>Bottled Fanta</option>"; echo"<option>Bottled Sprite</option>"; echo"<option>Bottled RootBeer</option>"; echo"</select>"; echo"Drink size2: <select name='DSIZE2'>"; echo"<option></option>"; echo"<option>.5 liter</option>"; echo"<option>1 liter</option>"; echo"<option>2 liter</option>"; echo"</select>"; echo"</br> <br/>What third drink would you like? <select name='DTYPE3'>"; echo"<option></option>"; echo"<option>No drink</option>"; echo"<option>Bottled Pepsi</option>"; echo"<option>Bottled Fanta</option>"; echo"<option>Bottled Sprite</option>"; echo"<option>Bottled RootBeer</option>"; echo"</select>"; echo"Drink size3: <select name='DSIZE3'>"; echo"<option></option>"; echo"<option>.5 liter</option>"; echo"<option>1 liter</option>"; echo"<option>2 liter</option>"; echo"</select>"; echo"<br/> <br/> <input type='submit' value='submit your order' name='submit'>"; echo"</form>"; ?> </body> </html> and the second page Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Title of the document</title> <meta name="description" content="Type a Short Description Here" /> <meta name="keywords" content="type, keywords, here" /> <meta name="author" content="Your Name" /> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> <body> <?php print_r ($_REQUEST) ; $ORDER = $_POST['ORDER']; $PTYPE = $_POST['PTYPE']; $DTYPE = $_POST['DTYPE']; $PSIZE = $_POST['PSIZE']; $DSIZE = $_POST['DSIZE']; $PTYPE2 = $_POST['PTYPE2']; $DTYPE2 = $_POST['DTYPE2']; $PSIZE2 = $_POST['PSIZE2']; $DSIZE2 = $_POST['DSIZE2']; $PTYPE3 = $_POST['PTYPE3']; $DTYPE3 = $_POST['DTYPE3']; $PSIZE3 = $_POST['PSIZE3']; $DSIZE3 = $_POST['DSIZE3']; if (($PTYPE=='cheese')and($PSIZE=='Small')) { $PCOST=10 ; }elseif (($PTYPE=='cheese')and($PSIZE=='Medium')) { $PCOST=13 ; }elseif (($PTYPE=='cheese')and($PSIZE=='Large')) { $PCOST=15 ; }elseif (($PTYPE=='pepporoni')and($PSIZE=='Small')) { $PCOST=12 ; }elseif (($PTYPE=='pepporoni')and($PSIZE=='Medium')) { $PCOST=14 ; }elseif (($PTYPE=='pepporoni')and($PSIZE=='Large')) { $PCOST=16 ; }elseif (($PTYPE=='veggie')and($PSIZE=='Small')) { $PCOST=12 ; }elseif (($PTYPE=='veggie')and($PSIZE=='Medium')) { $PCOST=14 ; }elseif (($PTYPE=='veggie')and($PSIZE=='Large')) { $PCOST=16 ; }elseif (($PTYPE=='meat lovers')and($PSIZE=='Small')) { $PCOST=13 ; }elseif (($PTYPE=='meat lovers')and($PSIZE=='Medium')) { $PCOST=15 ; }elseif (($PTYPE=='meat lovers')and($PSIZE=='Large')) { $PCOST=17; }else { $PCOST=0 ; } if (($PTYPE2=='cheese')and($PSIZE2=='Small')) { $PCOST2=10 ; }elseif (($PTYPE2=='cheese')and($PSIZE2=='Medium')) { $PCOST2=13 ; }elseif (($PTYPE2=='cheese')and($PSIZE2=='Large')) { $PCOST2=15 ; }elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Small')) { $PCOST2=12 ; }elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Medium')) { $PCOST2=14 ; }elseif (($PTYPE2=='pepporoni')and($PSIZE2=='Large')) { $PCOST2=16 ; }elseif (($PTYPE2=='veggie')and($PSIZE2=='Small')) { $PCOST2=12 ; }elseif (($PTYPE2=='veggie')and($PSIZE2=='Medium')) { $PCOST2=14 ; }elseif (($PTYPE2=='veggie')and($PSIZE2=='Large')) { $PCOST2=16 ; }elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Small')) { $PCOST2=13 ; }elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Medium')) { $PCOST2=15 ; }elseif (($PTYPE2=='meat lovers')and($PSIZE2=='Large')) { $PCOST2=17; }else { $PCOST2=0 ; } if (($PTYPE3=='cheese')and($PSIZE3=='Small')) { $PCOST3=10 ; }elseif (($PTYPE3=='cheese')and($PSIZE3=='Medium')) { $PCOST3=13 ; }elseif (($PTYPE3=='cheese')and($PSIZE3=='Large')) { $PCOST3=15 ; }elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Small')) { $PCOST3=12 ; }elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Medium')) { $PCOST3=14 ; }elseif (($PTYPE3=='pepporoni')and($PSIZE3=='Large')) { $PCOST3=16 ; }elseif (($PTYPE3=='veggie')and($PSIZE3=='Small')) { $PCOST3=12 ; }elseif (($PTYPE3=='veggie')and($PSIZE3=='Medium')) { $PCOST3=14 ; }elseif (($PTYPE3=='veggie')and($PSIZE3=='Large')) { $PCOST3=16 ; }elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Small')) { $PCOST3=13 ; }elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Medium')) { $PCOST3=15 ; }elseif (($PTYPE3=='meat lovers')and($PSIZE3=='Large')) { $PCOST3=17; }else { $PCOST3=0 ; } if((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='.5 liter')) { $DCOST=.69 ; }elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='1 liter')) { $DCOST=.99 ; }elseif((($DTYPE=='Bottled Pepsi')or($DTYPE=='Bottled Fanta')or($DTYPE=='Bottled Sprite')or($DTYPE=='Bottled RootBeer'))and($DSIZE=='2 liter')) { $DCOST=1.69 ; }elseif($DTYPE=='No drink'){ $DCOST=0 ; } if((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='.5 liter')) { $DCOST2=.69 ; }elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='1 liter')) { $DCOST2=.99 ; }elseif((($DTYPE2=='Bottled Pepsi')or($DTYPE2=='Bottled Fanta')or($DTYPE2=='Bottled Sprite')or($DTYPE2=='Bottled RootBeer'))and($DSIZE2=='2 liter')) { $DCOST2=1.69 ; }elseif($DTYPE2=='No drink'){ $DCOST2=0 ; } if((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='.5 liter')) { $DCOST3=.69 ; }elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='1 liter')) { $DCOST3=.99 ; }elseif((($DTYPE3=='Bottled Pepsi')or($DTYPE3=='Bottled Fanta')or($DTYPE3=='Bottled Sprite')or($DTYPE3=='Bottled RootBeer'))and($DSIZE3=='2 liter')) { $DCOST3=1.69 ; }elseif($DTYPE3=='No drink'){ $DCOST3=0 ; } $TOTAL=($PCOST+$PCOST3+$PCOST3+$DCOST+$DCOST2+$DCOST3) ; echo "<br/><br/>Your Order is:<br/>" ; echo " $PSIZE $PTYPE ($PCOST),$PSIZE2 $PTYPE2 ($PCOST2),$PSIZE3 $PTYPE3 ($PCOST3), <br/>" ; echo " $DSIZE $DTYPE ($DCOST),$DSIZE2 $DTYPE2 ($DCOST2),$DSIZE3 $DTYPE3 ($DCOST3), <br/> <br/>" ; echo"<br/><br/>Your total price is: $TOTAL <br/> <br/>"; if ($ORDER=='delivery') { echo"Please enter the information required for delivery <br/>" ; echo "Address: <input type=text><br/>"; echo "City: <input type=text><br/>"; echo "Zip Code: <input type=text><br/>"; } elseif ($ORDER=='takeout') { echo "Your order will be ready for pickup in 30 min"; } elseif ($ORDER=='eatin') { echo "Your order will be ready in 30 min"; } echo"<form action=asdf.php>"; echo"<br/> <input type=submit value='confirm this order'>"; echo"</form>"; echo "<form action=project.php>"; echo "<br/> <br/><input type=submit value='edit this order'>"; echo "<input type='hidden' name='ORDER' value='$ORDER'>"; echo "<input type='hidden' name='PTYPE' value='$PTYPE'>"; echo "<input type='hidden' name='PTYPE2' value='$PTYPE2'>"; echo "<input type='hidden' name='PTYPE3' value='$PTYPE3'>"; echo "<input type='hidden' name='PSIZE' value='$PSIZE'>"; echo "<input type='hidden' name='PSIZE2' value='$PSIZE2'>"; echo "<input type='hidden' name='PSIZE3' value='$PSIZE3'>"; echo "<input type='hidden' name='DTYPE' value='$DTYPE'>"; echo "<input type='hidden' name='DTYPE2' value='$DTYPE2'>"; echo "<input type='hidden' name='DTYPE3' value='$DTYPE3'>"; echo "<input type='hidden' name='DSIZE' value='$DSIZE'>"; echo "<input type='hidden' name='DSIZE2' value='$DSIZE2'>"; echo "<input type='hidden' name='DSIZE3' value='$DSIZE3'>"; echo "</form>"; ?> </body> </html> I have sort of an odd request. I wish make a POST to roblox.com with the Xsrf token, let me give you what code might help then ill explain more.
So, I need to parse the page http://www.roblox.co...spx?gid=1039951 to get
the token, which is between the (' ') below (this is taken from the site, as an example and the token changes each time the page refreshes/changes.
<script type="text/javascript">Roblox.XsrfToken.setToken('IVzHt8XOUJpy');</script>After you get the token, I need to make a post with that token to http://www.roblox.co...nge-member-rank with the variables: groupId= newRoleSetId= , targetUserId= , X-CSRF-TOKEN: IVzHt8XOUJpy, X-Requested-With: XMLHttpRequest I also might need to log in? which I think is done like so: POST https://m.roblox.com/Login HTTP/1.1 Host: m.roblox.com Content-Length: 29 Content-Type: application/json {"username":"","password":""}but I am not sure, that is just something I found during my research. I know this is possible, I have seen it done multiple times in the past, and I think I have something going... Just not sure how to put it all together... I'm not sure if this belongs in the PHP or SQL sections or both but- Is it possible to insert form data (one record) into 2 different tables when I click submit? As is, I have 2 distinct log-in scripts each linked to 2 separate databases . I want to merge them into one log-in form that populates both tables(in different dbs). I don't want my visitors to log into 2 different forms. Can one form's action attribute send the POST data to two different processing scripts? and can the input from a text box be sent to 2 different fields? I don't have any code, I just wanted to know if it can be done or point me to a sample that I can work from. Hi all, I was wondering if it was possible and not too messy to have a single form page (html) and have it post to 2 or more PHP files? Surely this is something that is desirable and accomplished at some point, right? Thanks. Richard Hi, I'm having a bit of a problem sharing some variables I have across a few files. My first file (index.php) calls an ajax request for (display.php) and sends a few variables to it. All fine so far. display.php then does its thing and displays the content on index.php as it should. Now in display.php I need a variable to be passed back to index.php for use in a menu. I've tried setting a session variable in display.php but unfortunately this doesn't seem to work. I also can't use get or post as I don't want to refresh the page. Really scratching my head over this one! Edd Is there anyway I can like "exit" the variables so i can use the same variable name later in the page? hello, im wondering how to properly code the following. Code: [Select] $stdate = date( 'Ymd', strtotime($pdate) ); $sttime = date( 'His', strtotime($tstart1) ); $dtStart = ".$stdate.'T'.$sttime.'Z'"; echo "$dtStart"; i would like the echo to read 20110309T050000Z Hello everyone, I'm sitting here in a position where I can't work on my site or test any code, but my mind is racing about what I can do to solve a particular problem that I have. I won't get into the problem because it would take more time to type than I have right now, but I have an idea for a simple solution, just not sure if it will work or not. So, here's my question: Is it possible to have multiple session variables during a session? Such as: $email=$_SESSION['email']; $user=$_SESSION['userid']; If this is possible, my problem is solved (I think)... otherwise, I have to keep thinking about it. Thanks for any help! I have this function: Code: [Select] function echo_exist($pre1,$ee,$post1) { if ($ee!='') { return $pre1; return $ee; return $post1; } else { //do nothing } } But when I try to echo it Code: [Select] echo_exist("(","$row['payment_type']",")"); I get syntax error, unexpected T_ENCAPSED_AND_WHITESPACE If $row['payment_type'] exists, I want it to be displayed in parentheses like: (AUTO) I suspect it has to do with my ' characters for the associative array, but I am new with functions so perhaps it is the multiple arguments that are wrong? Hi, I want to send the following variable using the $_GET function: I have a form with multiple options to fill out (its a admin form) i want to make sure only one of the of the options are set, so im checking if the variable is empty with if ($variable1 != NULL) { $new_variable = "yep, this option was filled out"; } so if the form sent anything from the form with the value 'variable1' it then sets a new variable ($new_variable) Problem is i have multiple fields so i need to make sure if it finds a a variable is not empty, then too check if the others have anything in them too. If it does find another (meaning more than one has been filled out) echo an error (echo "you must only complete one option..") What is the best way to check if more than one variable exists? Sorry if i explained it complicated. Thank you Only the last row will update when I submit. I have this form (and one nerve left): <form action="" method="post" > echo" <input style=\"text-align:center\" type=\"text\" name=\"linkorder\" value=\"".$row['order']."\" /> <input type=\"hidden\" name=\"id\" value=\"".$row['id']."\"/> "; <input type="submit" name="updateorder" value="Save Order" /> </form> On Submit: if (isset($_POST['updateorder'])){ connect(); $changeorder = mysql_unbuffered_query("update links set `order` = '".$_POST['linkorder']."' where id = '".$_POST['id']."'") or die(mysql_error()); } I was going put my fist through the monitor but then I remembered I could get help here. Thank you! Hi Guys and Girls, Long time lurker, first time poster! I am usually able to read through the forums and find and answer without having to start a new thread but I've tried my best to no avail. I am having trouble with the following code: $afname="Gareth"; $alname="B"; $awayoption.="<OPTION VALUE=\"".$afname." \"".$alname."\">".$afname." ".$alname; I would want that to produce the following: Code: [Select] <OPTION VALUE=Gareth B">Gareth B The actual result at the moment is: Code: [Select] <OPTION VALUE="Gareth "B">Gareth B It has an extra " in the middle. Any ides or help would be great! Cheers Hi, I have an affiliate system that shows results on what product is purchased. The problem is that the tracker is only listing the first product in the purchase list, so if someone purchases multiple products it only shows the first product in the transaction report. Here is the code: Code: [Select] $module = fetchDbConfig('PostAffiliatePro'); $orderInv = $order->getOrderInv($_GET["cart_order_id"]); print_r($orderInv); $affCode = "<!-- Begin PostAffiliatePro Affiliate Tracker --> <img border='0' src='".$module['URL']."/scripts/sale.php?TotalCost=".sprintf("%.2f", $orderSum['subtotal'])."&OrderID=".$cart_order_id."&ProductID=".$orderInv['0']['productCode']."' width='0' height='0' alt='' /> <!-- End PostAffiliatePro Affiliate Tracker -->"; ?> The code I need help with syntax is: Code: [Select] "&ProductID=".$orderInv['0']['productCode']."The products are split into arrays by number (0,1,2,3). So for example, I would want to show results for .$orderInv['0']['productCode']. , then .$orderInv['1']['productCode']. , and so on. I would like the results to be posted with a ; between them, but I don't know the proper syntax to have it report more than just the first array. This seems pretty simple, but I only know the basics of PHP and I've adapted this from found code. Any guidance would be greatly appreciated. Thanks! hello i have built a webpage using tables. i might have done something wrong (except using tables) and now the results are rendered chaotically on the webpage. also here is the attached file. after the 4th article it's all messy i have a solution but that means to insert a php tag inside another php tag, but won't work thankyou When a user logs into my site I was to store the user_name, user_role, and user_id in a session variable, then store this in a regular variable to make querying easier, but I am having issues with my code as its causing issues with my queries. Code: [Select] if (mysqli_num_rows($data) > 0) { //set sessions $row = mysqli_fetch_array($data); $_SESSION['username'] = $row['username']; $_SESSION['user_role'] = $row['role']; $_SESSION['user_id'] = $row['user_id']; //set variables $username = $_SESSION['username']; $user_role = $_SESSION['user_role']; $user_id = $_SESSION['user_id']; } Any ideas whats wrong?! Thanks for the help!! This will only send 1 goggles information into the database but I have a "adding" page that can actually add more than 1 goggles at once. I have no idea how to go about saving multiple goggle's information using array or loop. $name= $_POST['goggles_name']; $price = $_POST['goggles_price']; $des = $_POST['goggles_description']; $file = $_FILES['goggles_image']['name']; $chkbox = $_POST['upload']; $id = $_POST['goggles_id']; $query = "UPDATE goggles SET goggles_name = '$name' , goggles_price = '$price' ,goggles_description = '$des' WHERE goggles_id ='".$id."' "; $result = mysqli_query($link, $query) or die(mysqli_error($link)); I am creating a webpage for my golf league and some of the information(variables) such as Name, Address and email, must be reused across multiple pages for different outputs. May question is "Can I, or is there a way to reUse variables across multiple pages. "Do I need to create a session and make everything session variables"? "Should I link to a database and call the information when needed"? Any explanation would be greatly appreciated. |