PHP - Make Birth Year Sticky
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 Similar TutorialsHello, i have two fields. a beginning year and an ending year. How can i make new fields out of the years in between the beginning and ending years. i hope that makes sense. Since I didn't want to type it out myself I wrote a small Date of Birth drop down menu generator. Now I'm wondering how I can make the code copy-able in a text area? The script should be inserting all the code ready and finished into a textarea so you can copy and go. How is it done? Here's the script: <?php echo "<center>"; ?> <form action='' method='POST'> <input type='submit' name='submit' /> </form> <?php $submit = $_POST['submit']; if ($submit) { echo "<form action='' method='POST'>"; echo "<select name='month'>"; for ($m = 01; $m <= 12; $m++) { echo " <option value='" . $m . "'>" . $m . "</option> "; } echo "</select>"; echo "<select name='day'>"; for ($d = 01; $d <= 31; $d++) { echo " <option value='" . $d . "'>" . $d . "</option> "; } echo "</select>"; echo "<select name='year'>"; for ($y = 1900; $y <= 2010; $y++) { echo " <option value='" . $y . "'>" . $y . "</option> "; } echo "</select>"; echo "</form>"; echo "</center>"; } ?> 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> since 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 />"; } ?> Hi guys, My apologies if this is in the wrong forum but I am not really sure how to go about this. I have not written any code for this but I have four fields in one table one called age and 3 others dobmonth / dobday /dobyear - My question being how would I write some code that automatically fills in the age field based on the date of birth fields? If anyone could point me in the right direction that would be awesome, Appreciated. Is there a way to add a date of birth into a mysql but display it as the age?... e.g Mysql = 04/06/89 Display = 21 i have date of birth stored as DATE type in mysql. i tried this so it would show the age but it comes up blank. Code: [Select] $getprof = mysql_query("SELECT * FROM Profile WHERE username='$search'")or die(mysql_error()); while($rowprof = mysql_fetch_assoc($getprof)) { $username1 = $rowprof['username']; $location = $rowprof['location']; $gender = $rowprof['gender']; $dateofbirth = $rowprof['dateofbirth']; $information = $rowprof['information']; } function GetAge($dateofbirth) { // Explode the date into meaningful variables list($BirthYear,$BirthMonth,$BirthDay) = explode("-", $dateofbirth); // Find the differences $YearDiff = date("Y") - $BirthYear; $MonthDiff = date("m") - $BirthMonth; $DayDiff = date("d") - $BirthDay; // If the birthday has not occured this year if ($DayDiff < 0 || $MonthDiff < 0) $YearDiff--; return $YearDiff; } echo $YearDiff; Hi all, I'm having a bit of trouble a script running on a site where it converts a date of birth in a database shown like this '30/04/1993' to an actual age, for instance 18 in this case. Only the script I'm using below shows this age as 17, not 18 as it should be. Code: [Select] <?php $birthday = $row_getdets['dob']; function birthday ($birthday){ list($day,$month,$year) = explode("/",$birthday); $day_diff = date("d") - $day; $month_diff = date("m") - $month; $year_diff = date("Y") - $year; if ($day_diff < 0 || $month_diff < 0) $year_diff--; return $year_diff; } ?> So i've tried to remedy this myself with the following: Code: [Select] <?php $birthday = $row_getdets['dob']; function birthday ($birthday){ list($year,$month,$day) = explode("/",$birthday); $year_diff = date("Y") - $year; $month_diff = date("m") - $month; $day_diff = date("d") - $day; if ($month_diff < 0) $year_diff--; else if (($month_diff==0) && ($day_diff < 0)) $year_diff--; return $year_diff; } ?> ..but I'm having a syntax error (unexpected T_LINE), most probably down to my novice ability, I bet I've missed something simple. I'm still learning guys and I'd really appreciate any help at all. hello fellas, need some help please if possible. i have created a date of birth section in my form where the user selects his/her date of birth from the dropdown menu. they would first select the day then month then year of their birthday. how would i setup the database to get this to work? i currently have: Code: [Select] day VARCHAR( 2 ) NOT NULL , month VARCHAR( 4 ) NOT NULL , year VARCHAR( 4 ) NOT NULL , is this correct? many thanks Hi there, I'm new to PHP so sorry if this is a really basic question. How do i post date of birth collected from a form, into a database? I have the fields in the form set up as 'day' 'month' 'year' all of which are drop-down boxes. I tried doing it one way which i saw on a different website, but it didn't work. Here is what i tried: Code: [Select] '$_POST[day] . - . $_POST[month]' . - . $_POST[year]', More info: In the database table this information is going to, the "date of birth" field is set to "DATE" type. Don't know if that makes any difference $username = $_POST['username']; $password = $_POST['password']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $query = mysql_query("INSERT INTO users VALUES ('','$username','$password','$month','$day','$year') mysql_query($query); The code above is a sample of what I have but what I want is to store an entire birthdate in ONE SQL cell. More like this... $username = $_POST['username']; $password = $_POST['password']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $query = mysql_query("INSERT INTO users VALUES ('','$username','$password','$birthdate') mysql_query($query); How is this possible? Can I do this and actually use it efficiently in the future? I need to add date of birth field to registration form and then save it to databse. I cannot figure out what might be best way of storing the date in the table. I could convert it to unix epoch time, or I could do YYYYMMDD.
Thoughts? What would be the easiest method of saving the DOB?
I am not asking on how to do it, just the format. Thanks
Can you please help how to validate the date of birth in code igniter including leap years
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 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 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()); } } ?> Why does this work: $dateAllowedSelect = date('Y') -18; But this doesn't: $dateAllowedSelect = date('Y') +5; I nee to get the current year plus 2010 - 2015 in a select box. Thank you. 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> |