PHP - Array And Sticky Problems
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> Similar Tutorialsi have a users online section and i am using an aray and implode so the comma is displayed on every username but the last, but it displays the same usernames several times. This could be due to the switch i am using to define user group. Heres the code: $online_query = $db->query("SELECT user_id, user_group, user_username FROM ".DB_PREFIX."sessions"); while ($online_info = mysql_fetch_object($online_query)) { switch($online_info->user_group) { case 1: $userClass = 'admin'; break; case 2: $userClass = 'mod'; break; case 3: case 0: default: $userClass = 'user'; break; } $users2[] = "<span class=\"{$userClass}\">{$online_info->user_username}</span>"; echo '<p>' . implode(', ', $users2) . '</p>'; } is there something i am doing wrong? I am trying my hand at using an array i have never done it before, and I am having some problems getting it work work. if someone could point me in the right direction? Thanks <?php $active_keys = array(); foreach($_GET['img'] as $key => $filename) { if(!empty($filename)) { $active_keys[] = $key; } } ?> Hello,
Can anyone tell me what I'm doing wrong here? I am trying to run a query against a table for scenes from movies. Each movie would have up to 8 scenes. For the life of me I can't get this loop to work. The movie id is being passed in the url, tested to make sure it's being passed and it is. The code is pasted below.
require_once ('../mysqli_connect.php'); $movie_id = $_GET['movie_id']; $q = "SELECT * FROM scenes WHERE movie_id = $movie_id"; $r = @mysqli_fetch_array($dbc, $q); $row = @mysqli_fetch_array($r, MYSQLI_ASSOC); while ($row = @mysqli_fetch_array($r, MYSQLI_ASSOC));{ echo '<a href=" '.$row['scene_id'].'.mp4 ">'.$row['scene_name'].'</a>';}In advance thanks a million!! Edited by Zane, 28 May 2014 - 10:01 AM. I'd like some help debuging my code, I can't seem to figure out why it isn't creating the variables... Here it is: <?php $template_settings = array( "index"=>"index.php", "announcements"=>"announcements.php" ); extract($template_settings, EXTR_PREFIX_ALL, "template_"); echo $template_index; ?> No matter what I do $template_index still equals null and I'm wondering what I'm doing wrong. There are no errors of anykind. Problem: my checkbox array chkBrand[] is not saving data when I click the save button called cmdSave. Each checkbox specifies a brand connected to a model number. Multiple brands can be connected to each model number. (Don't ask, it's what the customer wants.) So, if I check the checkbox in row 0 and row 3, only row 0 shows up. If I check the boxes in row 0, 1, 5, only rows 0, 1 show up in chkBrand and $newchkbrandarr. First, my routine to see which button is checked is at the top of the php file. Here it is. else if (isset($_POST['cmdSave'])) //Try to save items first. { $newchkbrandarr=$_POST['chkBrand']; //Checkbox for each brand. $oldchkbrandarr=$_SESSION['oldchkbrandarr']; $olddata=$_SESSION['olddata']; //Non-brand Fields strung together. $brandlist=$_SESSION['brandlist']; //List of brands displayed. crPrintarr('chkBrand raw',$_POST['chkBrand']); //DEBUG. Prints array to screen. //===At this point chkBrand[] contains: 1 //Turn nulls in checkboxes to zeros. $cnt=count($newchkbrandarr); for ($j=0; $j<$cnt; $j++) { $newchkbrandarr[$j]=$newchkbrandarr[$j]+0; } //for j //Make sure that at least one brand is checked. $cnt=count($newchkbrandarr); crPrintarr('newchkbrandarr',$newchkbrandarr); //DEBUG //===At this point, $newchkbrandarr contains: 1, 0 $s='Elements in newchkbrandarr cnt='.$cnt; $s.=', count brandlist='.count($brandlist); crDebug($s); //DEBUG $cnt2=0; $cnt=count($newchkbrandarr); //Find number of elements. for ($j=0; $j<$cnt; $j++) { $cnt2=$cnt2+$newchkbrandarr[$j]+0; //$s='arrpos '.$j.': newchkbrandarr='.($newchkbrandarr[$j]+0).', cnt2='.$cnt2; //crDebug($s); //DEBUG } # for j Here is my code to construct the array of checkboxes, one per table row. Each checkbox has its array position explicitly defined as $x. $x starts at zero, and is incremented by 1 for each table row (each check box). $x=0; while ($row = mysqli_fetch_array($result)) { $br=trim($row['brand']); //Brand name to display $brandvar=$br; $brandlist[]=$br; //Save every found brand for later. //First find if brand is checked on table "brands". $query2 = "SELECT brand ". "FROM brands ". "WHERE ". "(partid=".$partidvar.") ". "AND (brand='".$br."') ". "ORDER BY brand ". ";"; $cntchk=crqryCount($query2,false); //If $cntchk>0 then brand is checked. //$s="Is brand stored already? <br/>$query2"; //crDebug($s); //DEBUG $query2 = "SELECT brand ". "FROM zzbrands ". "WHERE (brand='".$br."') ". "AND (prodnameoverride=1) ". "ORDER BY brand ". ";"; $override=crqryCount($query2,false); //Can this brand override product name? $s="\n"; $s.='<tr><td>'. '<input type="text" value="'.$br.'" id="txtBrand[]" name="txtBrand[]" '. 'size="20" readonly class="mydisabled" />'; $s.='<td align="center">'; $s.='<input type="checkbox" name="chkBrand['.$x.']" '. 'id="chkBrand['.$x.']" value="1" '; if ($cntchk>0) { $s.='checked="checked" '; $oldchkbrandarr[$x]=1; } else { $oldchkbrandarr[$x]=0; } $s.='/>'; Any ideas what I might be missing? I have a db table with 1500 street names inside - id, tfare, ptown, pcode, area. The 'area' column is specific to the company i work for and each street belongs to an 'area' number defined by the company. Currently each area is '0' - unassigned. The company areas are numbered 1 - 18. I need to list each street (LIMIT 10 at a time), and have an input box for the area to be edited and saved. The following code works perfectly well when dealing with 1 record at a time (LIMIT 0, 1), but breaks when i change the LIMIT to 10. I'm trying to show the dinosaur management that we need to upgrade our paper, yes, paper system to computers. I'm a transport manager, but in my spare time since 2004 I'm fluent in HTML and CSS, but only in the last few months really decided to give PHP and MySQL a *real* go. I'm 'guessing' I need to look into arrays for this to work? I've tried searching about but I dont even know how to articulate what i need to search for, so I have to publicly ask for help via this long winded post, sorry Here is my code: <?php include($_SERVER['DOCUMENT_ROOT'].'/!SYSTEM/bootstrap.php'); if(isset($_POST['savearea'])) { $id = $_POST['hideID']; $area = $_POST['area']; $sql = "UPDATE bmth_streetindex SET area='$area' WHERE id='$id'"; if ($query = mysql_query($sql)or die(mysql_error())) { print "saved ???"; } } // grab data from bmth street index where the area is = 0 (which means its area is un-assigned) $sql = "SELECT * FROM bmth_streetindex WHERE area='0' LIMIT 0, 10"; $rs = mysql_query($sql) or die(mysql_error()); print $HTML::form('action="" name="inputAreaForm" method="POST"')."\n\n"; // 'while' thru and print them 1 at a time while($row = mysql_fetch_array($rs)) { $id = $row['id']; $tfare = $row['tfare']; $ptown = $row['ptown']; $pcode = $row['pcode']; $area = $row['area']; $urlQ = $tfare. ", " .$ptown. ', ' .$pcode; print "<div>\n"; print "\n<input type=\"hidden\" name=\"hideID\" value=\"$id\">"; print "\n[$id] $tfare, $ptown, $pcode "; print "\nArea <input type=\"text\" name=\"area\" value=\"$area\" />"; print "\n<input type=\"submit\" name=\"savearea\" value=\"Save Area\">"; print "\n<a href=\"http://www.google.com/maps?q=$urlQ&hl=en&ie=UTF8&z=17\" target=new>SHOW ON MAP</a>"; print "\n<>\n<hr>\n\n"; } print $HTML::endForm(); ?> Thank you for taking the tie to read this, I hope someone can point me in the right direction for what i need to look into making this work Having problem with a bit of code. I am trying to fetch data from the database, I have used mysql_fetch_array before, and even in later bits of code. I want to use this data for an IF statement later on. The IF statement isn't there, because this code is catching somewhere. The fetch array is working fine, and it echos out the correct row in database that it should. The issue, it stops displaying code that follows it. In the code, I have put a comment (// Code kills here ....) where the code is killing. I have identified the few lines of code that is killing the script. You can see the page.. The number 71 is what is supposed to be supplied by the query and array. This is the page as it is with the trouble code. Here is the page without the trouble bit of code, and it displays all that it should. But it doesn't have the functionality I want to build in with the array obviously. Here is the code with highlight bit of trouble: /source/userinfo.php Code: [Select] <?php include ("db.php"); $get_info = mysql_query ("SELECT * FROM registrations WHERE u_id=$uid AND appid=$appid" , $link2); //Begin Trouble Code while ($check = mysql_fetch_array($get_info)) { echo $check['assign_id']; } //End Trouble Code // Code kills here, for some reason.... Proper assign_id displayed, but it kills script. $count = mysql_num_rows($get_info); if ($count >= 1) { $get_jos_info = mysql_query ("SELECT * FROM jos_users WHERE id=$appid" , $link); $get_avatar = mysql_query ("SELECT * FROM jos_comprofiler WHERE user_id=$appid" , $link); while ($avatar_link = mysql_fetch_array($get_avatar)) $avatarurl = $avatar_link['avatar']; echo $avatar_link['avatar']; echo "<table border='0' width='70%' align='center' cellpadding=5>"; while ($rowteam = mysql_fetch_array($get_info)) { while ($rowjos = mysql_fetch_array($get_jos_info)) { $urlbegin = "<img src='http://versionxlegends.com/images/comprofiler/tn"; $urlend = "'>"; echo "<tr><td width=100% align=center colspan=2>".$urlbegin.$avatarurl.$urlend."</td></tr>"; echo $avatar; echo "<tr><td width=40% align=right><strong>Registration #</strong></td><td width=60% align=center>$rowjos[id]</td></tr>"; echo "<tr><td width=40% align=right><strong>User's Username</strong></td><td width=60% align=center>$rowteam[username]</td></tr>"; echo "<tr><td width=40% align=right><strong>User's Name</strong></td><td width=60% align=center>$rowteam[name]</td></tr>"; echo "<tr><td width=40% align=right><strong>Provided Skype Username</strong></td><td width=60% align=center>$rowteam[skype]</td></tr>"; //Add script for lead only view Email Address. Team Member, field is hidden. Lead sees email and a YES/NO if email matches. If not, lead will email user to get email verification, to edit account before assignments occur. echo "<tr><td width=40% align=right><strong>E-Mail Address</strong></td><td width=60% align=center>$rowteam[email]</td></tr>"; echo "<tr><td width=40% align=right><strong>Registration Date</strong></td><td width=60% align=center>$rowjos[registerDate]</td></tr>"; // Add script for lead only view age. Team Member, field is hidden. Lead sees birthdate and/or age and a YES/NO if age matches. If not, lead will email user with ID verification e-mail, to verify age before assignments occur. echo "<tr><td width=40% align=right><strong>Age</strong></td><td width=60% align=center>$rowteam[age]</td></tr>"; }} echo "</table>"; } else { echo "Invalid URL. Registration does not exist"; } ?> This code is included within this page: viewregistration.php Code: [Select] <?php session_start(); $user_id = $_SESSION['user_id']; $uid = $_GET['u_id']; $appid= $_GET['appid']; include ("db.php"); $get = mysql_query ("SELECT * FROM registrations WHERE u_id = $uid AND appid=$appid", $link2); echo $get; ?> <!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=windows-1252" /> <title>Nuke Ice By ThemeKings</title> <link rel="stylesheet" type="text/css" href="nuke-ice.css" /> </head> <body> <div id="wrapper"> <div id="banner"> <div id="banner-edit"></div> </div> <div id="container"> <?php include ("sidebar.php"); ?> <div id="col-2"> <?php $uid = $_GET['uid']; $appid= $_GET['appid']; ?> <div class="CntBox"> <div class="CntHead"> <div class="CntHeadInfo">User Information</div> </div> <div class="CntFill"> <div class="CntInfo"> <?php include ("./source/userinfo.php"); ?> </div> </div> <div class="CntFooter"></div> </div> I included this bit of code so you can see some of the variables that were assigned in another file. Hi All,
I'm new to PHP (not to coding) - and I've been able to bang out most answers using books, the web and brue force - but this one has me stumped.
(If it's been covered before, sorry, I'm being lazy for not searching)...
So, here's the problem:
I have a call to my internal system that returns XML data via a SOAP call.
The call works great - data is returned as I would expect.
Like I've read, I put said data into a variable usng simpleXML like this: $xml = simplexml_load_string($response3); ($response3 being where the raw data is)
When I do a var_dump of $xml, I get this:
SimpleXMLElement Object ( [ICProductAvailByWhseResult] => SimpleXMLElement Object ( [errorMessage] => SimpleXMLElement Object ( ) [arrayAvailability] => SimpleXMLElement Object ( [ICProductAvailByWhse.output.Availability] => Array ( [0] => SimpleXMLElement Object ( [productCode] => xxx [description1] => yyy [description2] => zzz [warehouse] => aaa [netAvailable] => bbb ) [1] => SimpleXMLElement Object ( [productCode] => xxx [description1] => yyy [description2] => zzz [warehouse] => aaa [netAvailable] => bbb ) [2] => SimpleXMLElement Object ( [productCode] => xxx [description1] => yyy [description2] => zzz [warehouse] => aaa [netAvailable] => bbb ) **** Edited, I got real data, not xxx,yyy, etc... **** Now the issue: It seems like I have everything in place - all I need now is to get my data off to variables for display. I've tried everything I can think of and I just can't seem to get it. I ran $xml->getName() and it gave me: ICProductAvailByWhseResult So, simple I think, I should be able to print something like $xml->ICProductAvailByWhseResult[0]->warehouse and I should get something, right? Nope. So I try $xml->ICProductAvailByWhseResult[1]->warehouse and I get a notice that I'm trying to get to a property of a non-object. What am I missing? I come from a VB backgound, so I understand array's and such - but this one has be stumped. And help would be greatly appreciated... Thanks!! I have a text field in my database that I'm pulling the contents of and parsing into an array, at which point depending on the users action I'm either adding to the end or searching for a specific value and removing it. I'm then converting the array back to a string and placing it back into the text field in the database. Everything works fine except for either an empty array value or a new line forcing its way to the front. Causing, naturally an empty value loaded onto the page that displays this part of the db. While I know theres a couple things in there that aren't necessary I was just too lazy to take them out before posting after attempting to find a way around this problem. But here is the bulk of the code. I appreciate any help! $to_add = "SELECT * FROM teams WHERE name = '$teamname'"; $que_to_add = mysql_query($to_add); while ($fetch_members = mysql_fetch_array($que_to_add, MYSQL_BOTH)) { $members = explode("\n", $fetch_members['members']); $members = array_filter($members); foreach ($members as $key => $value) { $value = trim($value); $new_insert[] = $value; } } $new_insert = array_filter($new_insert); foreach ($new_insert as $key => $value) { if ($value != "") { $to_insert = ($to_insert . "\n" . $value); } } $to_insert = ($to_insert . "\n" . $for_insert); $insert_ready = "UPDATE teams SET members = '$to_insert' WHERE name = '$teamname'"; $insert = mysql_query($insert_ready); 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 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()); } } ?> 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%; } 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. 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> 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')?> Any help would br GREAT! This Post is about Sticky Forms and How to get them working. I would like to record the users input after processing it. I have the processing page redirecting back to the form page. I have been trying and trying and trying some more to re-display the users input, so they don't hav eto keep entering the same crap ova & ova. I would imagine this must be done using sessions given I am not using PHP Self fuction.. Here's what I have that does not work at all :-) This first code is on the process page. Code: [Select] <?php ob_start(); session_start(); $itemDescription=$_POST['itemDescription']; $itemPrice=$_POST['itemPrice']; $itemQty=$_POST['itemQty']; $bidderId=$_POST['bidderId']; $totalPrice=$_POST['totalPrice']; mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); if (isset($bidderId)) { $totalPrice=$itemQty * $itemPrice; mysql_query("INSERT INTO transactions (itemDescription, itemPrice, itemQty, bidderId, totalPrice) VALUES('$itemDescription', '$itemPrice', '$itemQty', '$bidderId', '$totalPrice')") or die(mysql_error()); $_SESSION['itemDescription']='$itemDescription'; header("Location: attendance.php"); exit(); } else echo "<font face= \"calibri\" size= \"3\" color= \"red\">You have left a field blank, please press your browsers back button. </font>"; exit(); ob_end_flush(); ?> Now How do I display the users input back to the form? Code: [Select] <?php session_start(); $itemDescription = ""; //item description, default as blank ?> <form action="record_trans.php" method="post"> <font face= "calibri" size= "4"> <table> <tr> <td><b>Item Description:</b></td> <td><input type= "text" name= "itemDescription" size= "30" value="<?php echo $itemDescription;?>"></td> </tr> <tr> <td><b>Item Price:</b></td> <td><input type= "text" name= "itemPrice" size= "5" value="<?php echo $itemPrice;?>"> </td> </tr> </tr> <td><b>Winning Bidders:</b></td> <td><input type="text" name= "bidderId" size= "5" /> </td> </tr> <tr> <td><b>How many deals?:</b></td> <td><input type="text" name= "itemQty" size= "3" value= "1" /></td> </tr> </table> <br/> <center><input type="submit" name="submit" value= "Save & Cont." " /></center> <center><input type="reset" value="Reset Form"></center> </form></font> [code] ALL SUGGESTIONS WELCOME- Before you leave give me ur take(if you have even a faint idea:-) Thanks Guys! I want a Text Area on my form where I can enter the body of an article. It should be sticky so the input is not lost if there are form issues and the form has to be re-loaded. The problem is that when I type "mmm" into this field, after I click "Submit" my form is reloaded - because I didn't complete it - and several blank lines appear before and after the text "mmm"?! Here is my code... Code: [Select] <!-- Body --> <li> <label for="body"><span class="required">*</span>Body:</label> <textarea id="body" name="body" class="text" cols="20" rows="5" wrap="soft"> <?php if(isset($body)){echo htmlentities($body, ENT_QUOTES);} ?> </textarea> <?php if (!empty($errors['body'])){ echo '<span class="error">' . $errors['body'] . '</span>'; } ?> </li> What seems to be the problem?! Debbie Some forum users here gave me great help yesterday in working with dropdown menus. In fact, I need quite a few of these dropdown menus in several forms over several pages, so I created several simple arrays and made a function to create the dropdowns. Here's one of my arrays: Code: [Select] <?php $instruments = array( 'Bassoon', 'Cello', 'Clarinet', 'Double Bass', 'Flute', 'French Horn', 'Oboe', 'Percussion', 'Trombone', 'Trumpet', 'Tuba', 'Viola', 'Violin', 'Other' ); Here's my function: Code: [Select] <?php function create_dropdown($array_name, $array_item) { echo "<select name='$array_item'>\n"; echo "<option value='select'>Select…</option>\n"; foreach( $array_name as $v ) { echo "<option value='$v'>" . $v . "</option>\n"; } echo "</select>\n"; } ... and anywhere I need a dropdown menu, I'm calling it like this: Code: [Select] <?php create_dropdown($instruments, 'instrument'); The dropdown menus, however (in some fairly detailed forms for my local youth orchestra's site), need to be sticky. How can I modify my function, above, so that the selected value will be retained if there are other form submission errors when the form is submitted? I have tried endlessly today but to no avail... If you can help while I still have some hair left, I'd be greatly appreciative. |