PHP - Make Selection List Sticky
I'm trying to get this drop down menu to be sticky once the user clicks submit.
Here's my entry code: Code: [Select] if (isset($_POST['guess'])) { if ($_POST['guess'] == $_SESSION['number']) { $response = "You Win!"; unset($_SESSION['number']); } else { $_SESSION['tries']++; if ($_SESSION['tries'] < 3) { $response = "Try #{$_SESSION['tries']}<br /><br />"; } else { $response = "You Lose"; unset($_SESSION['number']); } } } if (empty($_SESSION['number'])) { $_SESSION['tries'] = 0; $_SESSION['number'] = rand(1, 10); } And in my body: Code: [Select] <select name="guess" id="guess"> <?php for ($i = 1; $i < 11; $i++) { echo "<option value='{$i}'>{$i}</option>"; } ?> </select> Similar Tutorialssince many do not know the term sticky = when a form is submitted, the data contained is not deleted but instead last checked data will be shown. I have some dynamically generated checkboxes from the database. I tried the below code to make them sticky but they are simply preselected in stead of becoming sticky. What am I doing wrong? <?php $sql2 = "SELECT relation FROM table_rel_info"; $result2 = @mysqli_query($dbc, $sql2); while($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC)) { echo "<label>" . $row2['relation'] . "</label>"; echo "<input class='box' type='checkbox' value=1"; ?> <?php if (isset($row2['relation'])) { echo 'checked="checked"';}?> <?php echo "'/>" . "<br />"; } ?> I have PHP code that generates a long list of Birth Years in a Drop-down list, and I want to make the control "sticky". I know how to make something like this sticky - thanks to help from you guys... Code: [Select] <!-- Gender --> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="">--</option> <option value="F"<?php echo (isset($gender) && $gender == "F") ? 'selected="selected"' : ''; ?>>Female</option> <option value="M"<?php echo (isset($gender) && $gender == "M") ? 'selected="selected"' : ''; ?>>Male</option> </select> But my Birth Year code is a little more complex and I'm racking me brain how to do it... Code: [Select] <!-- Birth Year --> <label for="birthYear">Year Born:</label> <select id="birthYear" name="birthYear"> <option value="">--</option> <?php // Display dates for Users between 18 and 100. for($i = $newestYear; $i >= $oldestYear; $i--){ echo '<option value="' . $i . '">' . $i . '</option>'; } ?> </select> How do I make this second set of code "sticky"?? Thanks, Debbie Okay, really newbie question, but for this code... Code: [Select] <!-- Gender --> <label for="gender">Gender:</label> <select id="gender" name="gender"> <option value="">--</option> <option value="F">Female</option> <option value="M">Male</option> </select> 1.) How do I assign a variable to this? 2.) How do I make this "sticky"? Here is how I have usually done other form types... Code: [Select] <!-- First Name --> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" type="text" maxlength="30" value="<?php if(isset($firstName)){echo htmlentities($firstName, ENT_QUOTES);} ?>" /><!-- Sticky Field --> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> Oh, by the way, at the top of my PHP file I have this code... Code: [Select] if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). // Initialize Errors Array. $errors = array(); // Trim all form data. $trimmed = array_map('trim', $_POST); Thanks, Debbie if a user were to select multiple items in a selection list I would like to concatenate those items into a list and assign that into a variable. I know I should loop through the list but i'm not sure how I would continue to add those values to a variable. Hi I am pulling my hair out over this, I have tried many many ways on getting this to work but none have. I have a multi list selection box, which the user can select more than one option from. Once submitted this gets sent to a mysql database table. Below is my shortened version of the multi list html code: <select multiple="multiple" size="10" name="special[]"> <option value="Abdominal Training"> Abdominal Training </option> <option value="Aerobics"> Aerobics </option> <option value="Agility"> Agility </option> </select> If have tried putting [] which creates an array in the mysql table field special, but when I echo it back it just echos 'array'. When I try it without the [], and echo it back, it only echos one selection. I am still new to php, but have managed to get my head around a lot, but have been stuck on this for weeks, please help. Quote
I have this code here. i wanted to know how i can be able to make multiple selections from the returned data from the database and how to save them Quote
<select name="troom" multiple class="form-control" required> <option selected="true" disabled="disabled">--Select a room--</option> $records =mysqli_query($con, "select * from room where TRoom not in (select TRoom from roombook where cin <= '$checkout' and cout >= '$checkin');"); while ($data = mysqli_fetch_array($records)) { echo "<option value='" . $data['TRoom'] . "'>" . $data['TRoom'] . "</option>"; //displaying data in option menu } } ?> </select>
Hi I have to two multi list select boxes side by side. The first has all the options that the user can select which they can select and transfer to the other multi list select box. I have used javascript to create the buttons which allow you to add and remove selections from the right multi list box. Once I hit submit all the selections go to a mysql database, which is fine. However my problem is that the selected options don't stay in the right hand mulit list box after submission. So I need to know how I can keep them in there, or maybe populate that right hand multi list box with the submitted selections. FYI: once the selections are submitted they are stored in a text field in mysql database, so I need them to come back, as options in the right hand multi list box. Hope this makes sense Below is a link to something similar, just need to sort out the php side http://www.dhtmlgoodies.com/scripts/multiple_select/multiple_select.html Many Thanks Hi, I'm new to PHP/MySQL and need some help getting my query to work for my selection list: The selection list is built with: <form action='processformmissing.php' method='POST'> <fieldset> <legend>Choose Department</legend> <select name='depart'> <option value=''></option> <?php while ($row = mysqli_fetch_array($result)) { extract($row); echo "<option value='$department'>$department</option>\n"; } ?> </select> <p><input type='submit' value='Select Department' /></p> </fieldset> </form> The data is then sent to: $depart = $_POST['depart']; $deptlike = "%".$depart."%"; echo "<p>$depart</p>"; echo "<p>$deptlike</p>"; $query = "SELECT * FROM lifecerts INNER JOIN employees ON lifecerts.cid = employees.cid WHERE department LIKE '$deptlike' ORDER BY employees.name"; Hitting the submit button from my selection list form seems to be working fine because when I echo my data ($depart and $deptlike) it is giving me the correct value, but the query doesn't give me any results. However, if my post data comes from a text box instead of a selection list, my query works fine. Any thoughts on what I'm doing wrong??? Many thanks! I have a page with 3 drop down lists one for day of the month, one for month and one for year. what I am trying to do is use something that will enable me to make each day from the selected dates to appear as individual days. So if someone selected 1st of September and then 23rd of September it would show 1 2 3 4 5 up to 23. I need to be able to put this in a database. The make date is easy and I think I need to use explode but when I have seen this it comes out with 1, 2, 3, 4, and I do not want to use the comer. This is what I am using for the dates. Code: [Select] <?php $d = $_POST['d']; $m = $_POST['m']; $y = $_POST['y']; $d1 = $_POST['d1']; $m1 = $_POST['m1']; $y1 = $_POST['y1']; $date = date ("M-d-Y", mktime(0, 0, 0, $m, $d, $y)); $date1 = date ("M-d-Y", mktime(0, 0, 0, $m1, $d1, $y1)); ?> It will also have prices with these dates so if the user puts in 20.00 for day 1 it would need to go in for the dates selected. ie 1st 20.00 2nd 20.00 and so on. Any ideas or help would be appreciated Many Thanks Hi all.
how can i make the values show like a list. I tried html line break "<br>" and php \n but all to no avail. It just show all the values in one straigth line.
example of what i want is for the values to appear like this:
1234567890
0987654345
4567890675
instead of :
1234567890 0987654345 4567890675
Thanks
<form data-abide method="post" action=""> <div> <select name=""> <option value="name"> <?php $stmt = $pdo->query("SELECT acct_num FROM table order by id desc"); while ( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { echo $row['acct_num']; } ?> </option> </select> </div> <div> <label>New Password <small>required</small></label> <input type="password" name="password" id="password" required> <small class="error">New password is required and must be a string.</small> </div> <div> <label>Confirm New Password <small>required</small></label> <input type="password" name="password2" id="password2" required> <small class="error">Password must match.</small> </div> <input name="submit" type="submit" class="button small" value="Change Password"> </form> Edited by Mr-Chidi, 13 November 2014 - 01:34 AM. I have a folder containing files. I want to replace some characters in the file names (e.g. "_" with "-"), then make a list of new files (renamed ones). Thanks I am new to PHP and currently trying to develop a website... i am stuck at one place. Lets say i'm a user(mrX) that has 4 types of car that are Ferrari, Lamborghini, Evo and BMW. So, i will register to the system about my details and all of my car info such as their cc, transmission, plat number, engine capacity. Then, i will log on into the system and after log on, there will be a drop down list. If i pick Ferrari for example, under the drop down list there will be all the information about the car. The same on the other car also. Why is my First Name text box not "sticky" when my Form reloads due to data validation errors? Here is a snippet... Code: [Select] <!-- First Name --> <li> <label for="firstName"><b>*</b>First Name:</label> <input id="firstName" name="firstName" type="text" maxlength="20" value="<?php if(isset($firstName)){echo htmlspecialchars($firstName, ENT_QUOTES);} ?>" /><!-- Sticky Field --> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> </li> I was certain that this was working before, but who knows?! At the top of the same file if my Form Handling PHP code. Here is a snippet... // ************************************************************* // HANDLE FORM. * // ************************************************************* if ($_SERVER['REQUEST_METHOD']=='POST'){ // Form was Submitted (Post). // Initialize Variables. $_SESSION['resultsCode'] = ''; $errors = array(); // Trim all Form data. $trimmed = array_map('trim', $_POST); // Connect to the database. require_once(WEB_ROOT . 'private/mysqli_connect.php'); // ************************ // Validate Form Data. * // ************************ // Validate First Name. if (empty($trimmed['firstName'])){ $errors['firstName'] = 'Please enter your First Name.'; }else{ if (preg_match('#^[A-Z \'.-]{2,20}$#i', $trimmed['firstName'])){ $firstName = $trimmed['firstName']; }else{ $errors['firstName'] = 'First Name must be 2-20 characters (A-Z \' . -)'; } } Thanks, Debbie I have a form where users can send comments. The form sends the comments to me via e-mail. Why is the e-mail field not staying "sticky" after I click "Submit" yet the other fields are?? Code: [Select] <form id="comments" action="" method="post"> <ul> <!-- Sender's Email --> <li> <label for="senderEmail">Your E-mail:</label> <input id="senderEmail" name="senderEmail" class="text" type="text" maxlength="40" value="<?php if(isset($senderEmail)){echo htmlspecialchars($senderEmail, ENT_QUOTES);} ?>" /><!-- Sticky Field --> <?php if (!empty($errors['senderEmail'])){ echo '<span class="error">' . $errors['senderEmail'] . '</span>'; } ?> </li> <!-- Subject Line --> <li> <label for="subject">Subject:</label> <input id="subject" name="subject" class="text" type="text" maxlength="80" value="<?php if(isset($subject)){echo htmlspecialchars($subject, ENT_QUOTES);} ?>" /><!-- Sticky Field --> <?php if (!empty($errors['subject'])){ echo '<span class="error">' . $errors['subject'] . '</span>'; } ?> </li> Debbie I am trying to implement a sticky footer on my site, but I cannot get it to work. I've done it on about 5 sites prior to this, but this one is just not working.
The footer sticks to the bottom of the window, not the bottom of the document. I need it to be the bottom of the document.
This is the current state of the page: http://www.aspyrhosting.com/index.php
HTML:
<!DOCTYPE html> <html lang="en-US"> <head> <title></title> <meta charset="utf-8" /> <meta content="index, follow" name="robots" /> <meta content="0.0.1" name="revision" /> <link href="http://cdn2.aspyr.us/imgs/aspyrhosting/favicon.ico?v=0.0.1" rel="shortcut icon" /> <link href="http://cdn2.aspyr.us/css/aspyrhosting/style.css?v=0.0.1" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <header role="banner"> <section id="wrapper"> <div id="logoWrapper"> <img id="logo" src="./transparent.png?v=0.0.1" /> </div> <div id="headerRight"></div> </section> <section id="menuWrapper"> <div id="menuInnerWrapper"> <div id="menu"> </div> </div> <div id="searchbox"> Search: <input type="text" /> </div> </section> </header> <main id="content" role="main"> <p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p> </main> <footer> <section id="left"> <div id="copyright" role="copyright"></div> </section> <section id="right"> </section> </footer> </div> </body> </html>CSS: article, aside, figure, footer, header, hgroup, main, menu, nav, section{display: block;} html,body { margin:0; padding:0; height:100%; } #container { height:100%; min-height:100%; min-width: 1115px; position:relative; } header { } #logo { background: url('http://cdn2.aspyr.us/imgs/aspyrhosting/logo.png'); } main { padding-bottom: 100px; /* Height of the footer */ } footer { position:absolute; bottom:0; width:100%; height: 100px; /* Height of the footer */ background:#39f; } #menuWrapper { background: #080000; clear: both; width: 100%; height: 40px; } #menuInnerWrapper { float: left; width: 850px; } #menu { margin: 0 auto; width: 710px; } ul{ padding: 0 3px; margin: 0 auto; list-style-type: none; display: block; float: left; } ul li{ display: inline-block; padding: 0 5px; margin: 0 auto; text-align: center; height: 40px; width: 90px; line-height: 40px; } ul li a { text-decoration: none; color: #fff; } #searchbox { float: right; line-height: 40px; padding-right: 10px; min-width: 200px; width: 10%; } hi, I have a form in which some information is required but the username is optional however if it is left blank it says that username is taken please choose another one. how can I make it accept it if a username isn't entered? Code: [Select] <?php if (!isset($_SESSION)){ session_start(); } $fname=""; $lname=""; $username=""; $password=""; $reenterPassword=""; $address=""; $state=""; $city=""; $zip=""; $phone=""; $fax=""; $email =""; $re_enter_email =""; $payment = ""; $paypal_username=""; $ship_first_name=""; $ship_last_name=""; $ship_address=""; $ship_city=""; $ship_state=""; $ship_zip=""; $ship_email=""; $ship_re_email=""; $pet_name=""; $age=1; $breed=""; $pet_name2=""; $age2=1; $breed2=""; // Logout if(isset($_POST['logout'])){ unset($_SESSION['user']); } // Loading captcha file require_once('recaptchalib.php'); $privatekey = "6LdxwsoSAAAAAO4CWYDjkrGQsf5GXuIopJcC6SkE"; $publickey = "6LdxwsoSAAAAAFrZTLjBoDvLLjk9_NR_ubncL-24"; require_once("functions.php"); DatabaseConnection(); $state = $_POST['state']; $payment = $_POST['payment_Method']; $breed = $_POST['breed']; $ship_state=$_POST['Shipstate']; if((isset($_REQUEST["submit"]) && $_REQUEST["submit"]=="Log in") || $_SESSION['user']){ if(!$_SESSION['user']){ $login_username = isset($_REQUEST["username"])?$_REQUEST["username"]:""; $login_password = isset($_REQUEST["password"])?$_REQUEST["password"]:""; $msg = array(); if ($login_username == "") $login_msg['username_empty'] = "Please enter your name"; if ($login_password == "") $login_msg['password_empty'] = "Please enter your password"; $query = "SELECT * FROM customers WHERE username = '$login_username' AND password = '".$login_password."'"; }else{ $customer_id = $_SESSION['user']; $query = "SELECT * FROM customers WHERE customer_id='$customer_id'"; } if (!$login_msg){ $login_process = true; $result = mysql_query($query) or die("Database error: " . mysql_error()); if (mysql_num_rows($result) > 0){ $row = mysql_fetch_object($result); $customer_id = $row->customer_id; $_SESSION['user'] = $customer_id; $fname = $row->fname; $lname = $row->lname; $username=$row->username; $address=$row->address; $state=$row->state; $city=$row->city; $zip=$row->zip; $phone=$row->phone; $fax=$row->fax; $email =$row->email; $payment = $row->payment_method; $paypal_username=$row->paypal_username; $ship_first_name=$row->ship_first_name; $ship_last_name=$row->ship_last_name; $ship_address=$row->ship_address; $ship_city=$row->ship_city; $ship_state=$row->ship_state; $ship_zip=$row->ship_zip; $ship_email=$row->ship_email; $pet_name=$row->pet_name; $age=$row->age; $age_month=$row->age_month; $breed=$row->breed; $pet_name2=$row->pet_name2; $age2=$row->age2; $age_month2=$row->age_month2; $breed2=$row->breed2; }else{ $login_msg['login_fail'] = "Username, password combination is not valid."; } } } if(isset($_REQUEST["submit"]) && $_REQUEST["submit"]=="submit"){ $msg=array(); $fname=isset($_REQUEST["fname"])?$_REQUEST["fname"]:""; $lname=isset($_REQUEST["lname"])?$_REQUEST["lname"]:""; $username=isset($_REQUEST["lname"])?$_REQUEST["username"]:""; $password=isset($_REQUEST["lname"])?$_REQUEST["password"]:""; $reenterPassword=isset($_REQUEST["lname"])?$_REQUEST["reenterPassword"]:""; $address=isset($_REQUEST["address"])?$_REQUEST["address"]:""; $state=isset($_REQUEST["state"])?$_REQUEST["state"]:""; $city=isset($_REQUEST["city"])?$_REQUEST["city"]:""; $zip=isset($_REQUEST["zipcode"])?$_REQUEST["zipcode"]:""; $phone=isset($_REQUEST["phone"])?$_REQUEST["phone"]:""; $fax=isset($_REQUEST["fax"])?$_REQUEST["fax"]:""; $email =isset($_REQUEST["email"])?$_REQUEST["email"]:""; $re_enter_email =isset($_REQUEST["re_email"])?$_REQUEST["re_email"]:""; $re_enter_email= $email; $payment = isset($_POST['payment_Method'])?$_POST['payment_Method']:""; $paypal_username=isset($_REQUEST["PayPal_username"])?$_REQUEST["PayPal_username"]:""; $ship_first_name=isset($_REQUEST["Shipfname"])?$_REQUEST["Shipfname"]:""; $ship_last_name=isset($_REQUEST["Shiplname"])?$_REQUEST["Shiplname"]:""; $ship_address=isset($_REQUEST["Shipaddress"])?$_REQUEST["Shipaddress"]:""; $ship_city=isset($_REQUEST["Shipcity"])?$_REQUEST["Shipcity"]:""; $ship_state=isset($_REQUEST["Shipstate"])?$_REQUEST["Shipstate"]:""; $ship_zip=isset($_REQUEST["Shipzipcode"])?$_REQUEST["Shipzipcode"]:""; $ship_email=isset($_REQUEST["Shipemail"])?$_REQUEST["Shipemail"]:""; $ship_re_email=$ship_email; $pet_name=isset($_REQUEST["petName"])?$_REQUEST["petName"]:""; $age=isset($_REQUEST["age"])?$_REQUEST["age"]:''; $age=isset($_REQUEST["age_month"])?$_REQUEST["age_month"]:1; $breed=isset($_REQUEST["breed"])?$_REQUEST["breed"]:""; $nutritional_needs=isset($_REQUEST["nutritionalNeeds"])?$_REQUEST["nutritionalNeeds"]:""; $special_instructions=isset($_REQUEST["specialInstructions"])?$_REQUEST["specialInstructions"]:""; $pet_name2=isset($_REQUEST["petName2"])?$_REQUEST["petName2"]:""; $age2=isset($_REQUEST["age2"])?$_REQUEST["age2"]:""; $age2=isset($_REQUEST["age_month2"])?$_REQUEST["age_month2"]:1; $breed2=isset($_REQUEST["breed2"])?$_REQUEST["breed2"]:""; $nutritional_needs2=isset($_REQUEST["nutritionalNeeds2"])?$_REQUEST["nutritionalNeeds2"]:""; $special_instructions2=isset($_REQUEST["specialInstructions2"])?$_REQUEST["specialInstructions2"]:""; // Products information $product_name=isset($_REQUEST["productname"])?$_REQUEST["productname"]:""; $quantity=isset($_REQUEST["quantity"])?$_REQUEST["quantity"]:0; $price=isset($_REQUEST["price"])?$_REQUEST["price"]:0; $quantity_diff=isset($_REQUEST["quantity_diff"])?$_REQUEST["quantity_diff"]:0; $price_diff=isset($_REQUEST["price_diff"])?$_REQUEST["price_diff"]:0; $sales_tax=isset($_REQUEST["salestax"])?$_REQUEST["salestax"]:0; $subtotal=isset($_REQUEST["subtotal"])?$_REQUEST["subtotal"]:0; $shipping_cost=isset($_REQUEST["shippingcost"])?$_REQUEST["shippingcost"]:0; $total=isset($_REQUEST["total"])?$_REQUEST["total"]:0; // check for login if(isset($_POST['customer_id'])){ $customer_id = $_POST['customer_id']; $query = "SELECT * FROM customers WHERE customer_id='$customer_id'"; $result = mysql_query($query) or die("Database error: " . mysql_error()); if (mysql_num_rows($result) > 0){ $login_process = true; $_SESSION['user'] = $customer_id; $row = mysql_fetch_object($result); $fname = $row->fname; $lname = $row->lname; $username=$row->username; } } // Is username taken ? if(!$login_process){ $query = "SELECT * FROM customers WHERE username = '$username'"; $result = mysql_query($query) or die("Database error: " . mysql_error()); if (mysql_num_rows($result) > 0){ array_push($msg,"This username is already taken, please choose another one."); } } if($fname==""){ array_push($msg,"Please Enter First Name."); } if($lname==""){ array_push($msg,"Please Enter Last Name."); } /* if($username==""){ array_push($msg,"Please Enter User Name."); } if(!$login_process){ if($password==""){ array_push($msg,"Please Enter Password."); } if($reenterPassword==""){ array_push($msg,"Please Enter Re-Enter Password."); } if($reenterPassword!=$password){ array_push($msg,"Both passwords does not match."); } }*/ if($address==""){ array_push($msg,"Please Enter Address."); } if($city==""){ array_push($msg,"Please Enter City."); } if($state=="Please choose a state"){ array_push($msg,"Please Select State."); } if($zip==""){ array_push($msg,"Please Enter Zip."); } else { if(!is_numeric($zip)){ array_push($msg,"Please Enter Digits In Zip."); } } if($phone==""){ array_push($msg,"Please Enter Phone."); } else { if(!is_numeric($phone)){ array_push($msg,"Please Enter Digits In Phone."); } } if($email==""){ array_push($msg,"Please Enter Email."); } if($payment==""){ //array_push($msg,"Please Select Payment Method."); } if($paypal_username==""){ // array_push($msg,"Please Enter Paypal User Name."); } if($ship_first_name==""){ array_push($msg,"Please Enter Shipping First Name."); } if($ship_last_name==""){ array_push($msg,"Please Enter Shipping Last Name."); } if($ship_address==""){ array_push($msg,"Please Enter Shipping Address."); } if($ship_city==""){ array_push($msg,"Please Enter Shipping City."); } if($ship_state==""){ array_push($msg,"Please Select Shipping State."); } if($ship_zip==""){ array_push($msg,"Please Enter Shipping Zip."); } else { if(!is_numeric($ship_zip)){ array_push($msg,"Please Enter Digits In Shipping Zip."); } } if($ship_email==""){ // array_push($msg,"Please Enter Shipping Email."); } // Check Captcha $resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]); if (!$resp->is_valid) { array_push($msg,"Wrong Captcha, please try again."); } // Insert customer if($login_process){ $sql0 = "UPDATE customers SET address='$address',city='$city', state='$state', zip='$zip', phone='$phone', fax='$fax', email='$email', re_enter_email='$re_enter_email', ship_first_name='$ship_first_name', ship_last_name='$ship_last_name', ship_address='$ship_address', ship_city='$ship_city', ship_state='$ship_state', ship_zip='$ship_zip', ship_email='$ship_email', ship_re_enter_email='$ship_re_email', pet_name='$pet_name', age='$age', breed='$breed', pet_name2='$pet_name2', age2='$age2', breed2='$breed2', age_month='$age_month', age_month2='$age_month2' WHERE customer_id='$customer_id'"; if(count($msg) == 0){ $r= mysql_query($sql0) or die("Query Error : " . mysql_error()); $customer = $customer_id; } }else{ $sql0="INSERT INTO customers (fname, lname,username,password, address, city, state, zip, phone, fax, email, re_enter_email, ship_first_name, ship_last_name, ship_address, ship_city, ship_state, ship_zip, ship_email, ship_re_enter_email , pet_name, age, breed, pet_name2, age2, breed2, age_month, age_month2) VALUES ('$fname', '$lname','$username','$password', '$address', '$city', '$state', '$zip', '$phone', '$fax', '$email', '$re_enter_email', '$ship_first_name', '$ship_last_name', '$ship_address', '$ship_city', '$ship_state', '$ship_zip', '$ship_email', '$ship_re_email', '$pet_name', '$age', '$breed', '$pet_name2', '$age2', '$breed2', '$age_month', '$age_month2')"; if(count($msg) == 0){ $r= mysql_query($sql0) or die("Query Error : " . mysql_error()); $customer = mysql_insert_id(); } } // Insert Order $sql1="INSERT INTO orders (product_name, customer, quantity, price, sales_tax, subtotal, shipping_cost, total, nutritional_needs, special_instructions, nutritional_needs2, special_instructions2) VALUES ('$product_name', '$customer', '$quantity_diff', '$price_diff', '$sales_tax', '$subtotal', '$shipping_cost', '$total', '$nutritional_needs', '$special_instructions', '$nutritional_needs2', '$special_instructions2')"; if(count($msg) == 0){ $m= mysql_query($sql1) or die("Query Error : " . mysql_error()); } } ?> Hey guys, I have a question that you can hopefully help me with, I'm writing a simple forum, and I'm wondering how I would go by handling a thread that has been 'stuck' so that it isn't moved when more threads are made. I could use some a push in the right direction thanks. I am having an issue with the data from page ID 5 not displaying in the form, Why <?php include('includes/header.php'); include('includes/class/class.form.php'); include('includes/class/class.page.php'); $iPageID = 5; if(isset($_GET["PageID"])){ $iPageID = $_GET["PageID"]; } $EditedPage = new Page(); $EditedPage->loadPage(5); $apageInformation = array(); // Information From DB Sticky $apageInformation["name"] = $EditedPage->getPageName(); $apageInformation["content"] = $EditedPage->getPageContent(); $formEdit = new Form('editpage.php?PageID=".$iPageID', 'EditPage','return CheckEditPage();',''); $formEdit->setStickyData($apageInformation); if(isset($_POST["submit"])){ $formEdit->setStickyData = $_POST; $formEdit->checkNotEmpty("Name"); $formEdit->checkNotEmpty("PageContent"); if($formEdit->getValid() == true){ $EditedPage->setPageName = $database->escape_value($_POST["Name"]); $EditedPage->setPageContent = $database->escape_value($_POST["PageContent"]); $EditedPage->savePage(); $Message = "Page Updated"; }else{ $Message = "You Have An Error Mate"; } } $formEdit->openFieldset(); $formEdit->makeInputBox("Name","Name","CheckInput(this.id);"); $formEdit->makeTextArea("Content", "PageContent", "20","70", "CheckInput(this.id);"); $formEdit->makeSubmitButton("submit","Edit Page"); $formEdit->closeFieldset(); $newNavigation = new Navigation(); ?> <?php echo $newNavigation->mainMenu();?> <h1 class="Heading">Edit Page</h1> <?php echo $Message ?> <?php echo $formEdit->getHTML(); ?> <?php include('includes/footer.php')?> Hi, I'm trying to make a form sticky but when I display it on the web I get a blank page. I'm following the example given in my PHP book I'm wondering if there 's an error in the book because it has 2 opening form tags which I didn't think was right. Code: [Select] <!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>Untitled Document</title> </head> <body> <?php $errors=array(); if(isset($_POST['submit'])){ validate_input(); //checks for empty fields if(count($errors) !=0){ display_form(); } else { display_form(); } } function validate_input(){ global $errors; if($_POST["name"] == ""){ $errors['name']="<font color='red'> please enter your name </font>"; } } function display_form(){ global $errors; ?> <form action="" method="post"> Name: <input name="name" type="text" size="10" maxlength="10" value = "<?php echo $_POST[name]; ?>"/> <br /> <?php echo $errors['name']; ?> <br /> Email: <input name="email" type="text" size="15" maxlength="30" /><br /> <input name="submit " type="submit" value="submit " /> </form> <?php } ?> </body> </html> The code here is suppose to allow the user to match up a word ($word) with a list of definitions ($word_defs). I can't get the list of definitions to stick. When the user does make a guess it shows that he is always correct. How can i fix these problems? Outside entry code: Code: [Select] <?php require_once "include/session.php"; require_once "include/word_defs.php"; $word = array_keys($word_defs); $word_defs = array_unique(array_values($word_defs)); $params = (object) $_REQUEST; $session = new Session(); if (isset($params->guess)) { $word = $params->word; if ( $params->word == $word_defs[$term] ) { $response = "correct"; } else { $response = "incorrect"; } $choices->word_def[$params->word_def] = "selected"; } else { $word = $word[ rand( 0, count($word)-1 ) ]; } ?> Body code: Code: [Select] word: <?php echo $word ?> <form action="?" method="get"> definition: <select name="word_defs"> <?php foreach ($word_defs as $word_def): ?> <option <?php echo $choices->word_def[$word_def] ?> ><?php echo $word_def?></option> <?php endforeach ?> </select> <input type="submit" name="guess" value="Guess" /> <input type="hidden" name="word" value="<?php echo $word?>" /> </form> <h3><?php echo $response ?></h3> |