PHP - Php Ordering Form Help Please. Variables Staying The Same After Submit
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> Similar TutorialsI have a lottery PHP script which i have been creating. The lottery contains four different numbers in which are four different fields in my database. On the random ticket buy the code for the four numbers are like this $ticketone = rand(1,25); $tickettwo = rand(1,25); $ticketthree = rand(1,25); $ticketfour = rand(1,25); I am wanting to do it so they can be put in order and then imported into my database in that right order. For example, If ticketone was 20, an tickettwo was 13, i would want it to be imported into the database so that ticketone would be 13. (being put into order) and ticket two would be 20 etc.... Looking to INSERT a row in a data table and keeping the User on the current page. Will it work like what I have below, or do I need to send it to its own page then return the User back to where he started? What I have below isn't inserting a row. No errors showing. function bookmark_add () { if (isset($_POST['submit'])) { include("/home2/csi/public_html/resources/con.php"); $query = "INSERT INTO a_player_bookmark (bookmark) VALUES ('1')"; $results = mysqli_query($con,$query); echo mysqli_error($con); } $output = '<form name="bookmark_add" method="post" action="" class="bookmark-plus">'; $output .= '<span><input type="submit" name="Bookmark"></span>'; $output .= '</form>'; return $output; }
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... Say 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 Hi. Pretty straight forward I guess but as the name suggests am a newbie. I have a form that requires the user to enter certain parameters. If the values are blank it submits to itself and loads the error messages. What I want to do is create PHP code that submits the form to a different url. What I thought was create two forms (the second with hidden fields replicating the first form), each form having a different url in the action"" code. What I cant work out is the PHP IF ELSE code to submit form 2 if Form1 is is validated correctly. This is the PHP code relevant to the form validation. Help? <?php //If form was submitted if ($_POST['submitted']==1) { $errormsg = ""; //Initialize errors if ($_POST[width]){ $title = $_POST[width]; //If title was entered } else{ $errormsg = "Please enter width"; } if ($_POST[drop]){ $textentry = $_POST[drop]; //If comment was entered } else{ if ($errormsg){ //If there is already an error, add next error $errormsg = $errormsg . " & content"; }else{ $errormsg = "Please enter drop"; } } } if ($errormsg){ //If any errors display them echo "<div class=\"box red\">$errormsg</div>"; } //If all fields present if ($title && $textentry){ //Do something echo 'THIS IS WHERE I WANT THE CODE TO SUBMIT FORM 2 or SUBMIT FORM 1 TO A DIFFERENT URL'; } ?>
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. Hello, first time poster.. I've looked the web over for a long time and can't figure this one out. - Below is basic code that successfully checks MySQL for a match and displays result. I was debugging and forced the "height" and "width" to be 24 and 36 to make sure that wasn't the problem. That's good.. - I'd like to give the user ability to select width and height from a form.. and have it do an onchange this.form.submit so the form can be changing as fields are altered (thus the onchange interaction) - In a normal coding environment I've done this numerous times with no "Page cannot be displayed" problems. It would simply change one select-option value at a time til they get down the form and click submit... but in WordPress I'm having trouble making even ONE single onchange work! - I've implemented the plugins they offer which allows you to "copy+paste" your php code directly into their wysiwyg editor. That works with basic tests like my first bullet point above. - I've copied and pasted the wordpress url (including the little ?page_id=123) into the form "action" url... that didn't work... tried forcing it into an <option value=""> tag.. didn't work. I'm just not sure. I've obviously put xx's in place of private info.. Why does this form give me Page Cannot Be Displayed in WordPress every time? It won't do anything no matter how simple.. using onchange.. Code.. $con = mysql_connect("xxxx.xxxxxxx.com","xxxxxx","xxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxx", $con); $myprodwidth=24; $myprodheight=36; $result = mysql_query("SELECT * FROM product_sizes WHERE prodwidth='$myprodwidth' and prodheight='$myprodheight'"); while($row = mysql_fetch_array($result)) { echo $row['prodprice']; } mysql_close($con); <form method="post" action=""> <select name="myheight" onchange="this.form.submit();"> <option selected="selected" value="">select height</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">36</option> <option value="xxxxxxxxx.com/wordpress/?page_id=199&height=36">48</option> </select> Hi all, What I am trying to achieve is, I thought quite simple! Basically, a user signs up and chooses a package, form is submitted, details added to the database, email sent to customer, then I want to direct them to a paypal payment screen, this is where I am having issues! Is their any way in php to submit a form without user interaction? Here is my code for the form process page Code: [Select] <?php include('config.php'); require('scripts/class.phpmailer.php'); $package = $_POST['select1']; $name = $_POST['name']; $email = $_POST['email']; $password = md5($_POST['password']); $domain = $_POST['domain']; $a_username = $_POST['a_username']; $a_password = $_POST['a_password']; $query=mysql_query("INSERT INTO orders (package, name, email, password, domain, a_username, a_password) VALUES ('$package', '$name', '$email', '$password', '$domain', '$a_username', '$a_password')"); if (!$query) { echo "fail<br>"; echo mysql_error(); } else { $id = mysql_insert_id(); $query1=mysql_query("INSERT INTO customers (id, name, email, password) values ('$id', '$name', '$email', '$password')"); if (!$query1) { echo "fail<br>"; echo mysql_error(); } if($package=="Reseller Hosting") { //email stuff here - all works - just cutting it to keep the code short if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } ?> <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick-subscriptions"> <input type="hidden" name="business" value="subscription@jollyhosting.com"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="item_name" value="Jolly Hosting Reseller Packages"> <input type="hidden" name="no_shipping" value="1"> <!--1st month --> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="a3" value="3.00"> <input type="hidden" name="p3" value="1"> <input type="hidden" name="t3" value="M"> <input type="hidden" name="src" value="1"> <input type="hidden" name="sra" value="1"> </form>'; <?php } //last } //end ?> Hi- the code below lets me upload a CSV file to my database if I have 1 field in my database and 1 column in my CSV. I need to add to my db "player_id" from the CVS file and "event_name" and "event_type" from the form... any ideas??? here's the code: Code: [Select] <?php $hoststring =""; $database = ""; $username = ""; $password = ""; $makeconnection = mysql_pconnect($hoststring, $username, $password); ?> <?php ob_start(); mysql_select_db($database, $makeconnection); $sql_get_players=" SELECT * FROM tabel ORDER BY player_id ASC"; // $get_players = mysql_query($sql_get_players, $makeconnection) or die(mysql_error()); $row_get_players = mysql_fetch_assoc($get_players); // $message = null; $allowed_extensions = array('csv'); $upload_path = '.'; //same directory if (!empty($_FILES['file'])) { if ($_FILES['file']['error'] == 0) { // check extension $file = explode(".", $_FILES['file']['name']); $extension = array_pop($file); if (in_array($extension, $allowed_extensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_path.'/'.$_FILES['file']['name'])) { if (($handle = fopen($upload_path.'/'.$_FILES['file']['name'], "r")) !== false) { $keys = array(); $out = array(); $insert = array(); $line = 1; while (($row = fgetcsv($handle, 0, ',', '"')) !== FALSE) { foreach($row as $key => $value) { if ($line === 1) { $keys[$key] = $value; } else { $out[$line][$key] = $value; } } $line++; } fclose($handle); if (!empty($keys) && !empty($out)) { $db = new PDO( 'mysql:host=host;dbname=db', 'user', 'pw'); $db->exec("SET CHARACTER SET utf8"); foreach($out as $key => $value) { $sql = "INSERT INTO `table` (`"; $sql .= implode("`player_id`", $keys); $sql .= "`) VALUES ("; $sql .= implode(", ", array_fill(0, count($keys), "?")); $sql .= ")"; $statement = $db->prepare($sql); $statement->execute($value); } $message = '<span>File has been uploaded successfully</span>'; } } } } else { $message = '<span>Only .csv file format is allowed</span>'; } } else { $message = '<span>There was a problem with your file</span>'; } } ob_flush();?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>CSV File Upload</title> </head> <body> <form class="form" action="" method="post" enctype="multipart/form-data"> <h3>Select Your File</h3> <p><?php echo $message; ?></p> <input type="file" name="file" id="file" size="30" /> <br/> <label>Event Name:</label><input name="event_name" type="text" value="" /> <br/> <label>Event Type:</label><input name="event_type" type="text" value="" /> <br/> <input type="submit" id="btn" class="button" value="Submit" /> </form> <br/> <h3>Results:</h3> <?php do { ?> <p><?php echo $row_get_players['player_id'];?></p> <?php } while ($row_get_players = mysql_fetch_assoc($get_players)); ?> </body> </html> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=347360.0 Hi guys, Im building a website for a company http://www.eminence-logistics.co.uk and the client wants a log in system which im having problems with. The registration system is all working fine. If you go to the website you can see where the login form is. Now when the user isn't logged in i need the form to show, but when the user IS logged in i would like a message replacing the form saying welcome, along with a log out button. How do i do this? Thankyou very much Enlighten Hi. I'm new to php. I created a register, log in, welcome, and log out page for my site. They are all working accordingly. I'm having one problem that I can't seem to fix. I would like to stay logged in as I navigate other pages of my site. Everytime i click on a link to another page within my site I get logged out. I know this issue might pertain to using session but thats all I was able to find using google search. Can anyone help? Much appreciated. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=316188.0 Code: [Select] <?php if (isset($_POST['checking'])) { echo $_POST['checking']; } if (isset($_POST['test'])) { echo $_POST['test']; } ?> <form id="testform2" action="testform.php" method="post"> <select name="checking" onchange="this.form.submit()"><option value="5">5</option><option value="6">6</option></select> <input type="text" name"test" id="test"> <a href="#" onclick="this.form.submit()">submit it!</a> </form> It works when I try to submit by selecting a new value from the dropdown box but when I try to click the link it won't display the text field value. That is a test case for a problem I m having in one of my codes. Hi, I have setup a basic enquiry form with a Captcha - once the code has been inserted and is correct I want to action the form (submit) in PHP. <?php session_start(); if($_SERVER['REQUEST_METHOD'] == 'POST'){ $vResult = ''; if(strtolower($_SESSION['security_code']) != strtolower($_POST['security_code'])){ $vResult = 'Invalid code!'; } else{ "/enquiry.php" } } ?> I want to submit the form to /enquiry.php - I tried header(Location.. and realised that just redirects, and doesn't submit the form. Any suggestions or tips would be great. Cheers, Paul I can't submit php form using IE 8. This works fine on Firefox very well. I tried following code but none of them is working. 1. <button type="submit">Submit</button> 2. <input type="submit" value="Submit" name="submit"> I would appreciate if any one help me in this. Hi, I want to submit a form using ajax ans jquery with two fields input text and file. Code: [Select] <script> $(document).ready( function() { $('#basicinfofrm').ajaxForm(function() { url: ''+PN+'.php', type:'POST', data:'action=yes&'+frmFeilds, success: function(html) { alert(html); } }).submit(); </script> <form action='' method='post'> <label>name</label> <input type='text' name='txtname' /> <input type='file' name = 'txtfile' /> <input type='submit' value='save' /> </form> but is is not working... can anyone tell me how to? i don't want to refresh my page Thanks Can anybody see as to why, if any, this form takes forever to execute? Code: [Select] <?php if(isset($_POST['submitted'])){ $z = $_POST['zipcode']; $r = $_POST['radius']; $sql = mysql_query("SELECT DISTINCT m.LocAddZip, m.MktName,m.LocAddSt,m.LocAddCity,m.LocAddState,m.x1,m.y1,z1.lat,z2.long FROM mrk m, zip z1, zip z2 WHERE m.LocAddZip = z1.zipcode AND z2.zipcode = $z AND ( 3963 * acos( truncate( sin( z2.lat / 57.2958 ) * sin( z1.lat / 57.2958 ) + cos( z2.lat / 57.2958 ) * cos( z1.lat / 57.2958 ) * cos( z1.long / 57.2958 - z2.long / 57.2958 ) , 8 ) ) ) <= $r ") or die(mysql_error()); while($row = mysql_fetch_array( $sql )) { $store = $row['MktName']."<br />"; $store .= $row['LocAddSt']."<br />"; $store .= $row['LocAddCity'].", ".$row['LocAddState']." ".$row['LocAddZip']; $lat1 = $row['lat']; $lon1 = $row['long']; $lat2 = $row['y1']; $lon2 = $row['x1']; $dis = distance($lat1, $lon1, $lat2, $lon2); echo "<p>".$store."</p>"; echo ceil($dis) . " mile(s) away"; echo "<hr/>"; } } ?> I get a timeout error sometimes, and sometimes I don't. Is it the form, or would it be on the server? Thanks in advance hello everyone, I have a php form, everything works, I do not carry any header() at the end of the form because I have to stay on the same page and because I feel it wipes out the message you sent the form successfully, but for this though if reloading the page shows me the popup asking me to resend the form. how can i solve? I found a function in js with replacestate but I saw that it doesn't work with mobile Safari. if ( window.history.replaceState ) { window.history.replaceState( null, null, window.location.href ); }
I wrote this while loop to cycle through all the rows in my database, and for each row, to create two things, first to echo the name of the book, and the second was to create a button next to it that when clicked, sends the BookID of that row via the post method to the the page at /scas/moreinfo.php . The first echo statement works, and states every book name on the page one after another. For some reason however the form Posts the same book id in every form i think, the value of it being the value in BookID in the last row of the database, in this case 16, so no matter what button is pressed, it sends the value 16. What have I done wrong? while($row = mysql_fetch_array($result)) { echo $row['BookName'] ; echo "<form name='moreinfo' action='/scas/moreinfo.php' method='post'>"; echo "<input type='hidden' name='BookID' value='" .$row['BookID']. "'>"; echo "<input type='submit' value='More Info' />"; echo "<br />"; } |