Remember Selected Value DropDown
I am attempting to have a drop down menu that displays url from 1 table called links the same table also contains a name for the url. i.e. google.com = name and http://www.google.com = url The value of just the url from links is stored in a separate table called users in a field named search after form is submitted by user. Everything Posts correctly except when go back to edit the record and submit the form the drop down box does not retain the value of what had been previously selected although it is the correct record until form is updated when whatever value is currently in the drop down list will update the record.
I know the code is doing exactly what it is told to do, because I have no functionality in it to recall the value from the field search in the users table. I don't know if it is something I would have to add to the array or option value. I can get it to work if it is all hard coded, but I am attempting not to do this. I am pretty new to php mysql and any help is greatly appreciated.
This is the code I am working with that came mostly from a tutorial. PHP Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Remember Selected
How does a script remember selected qty when the user needs to edit an order form. echo"<select name ='blar'>"; for($num;$num<$num2;$num++) { echo"<option value = '$num'"; ........................... // here needs to be selected = 'selected' at the correct place?? echo">$num</option>";....
View Replies !
How To Get Form To Remember Selected Option?
I am now trying to make a form remember which color (a select list) they selected before pressing any of the submit buttons. I entered this code into the form: <select name="color"> <option value="red">red</option> <option value="blue">blue</option> </select> The submit is a GET type. For example, if the user selects blue and then clicks on either one of the "submit" buttons, I want the form to remember/show the blue option. Right now the select list always goes back to red, the first choice. I tried doing a <?php echo $red; ?> and <?php echo $blue; ?> for the option value, but this does not work since the select list needs a value.
View Replies !
Php Dropdown - Selected?
i'm using this to pull information from a database and display it in a dropdown list. The problem is I am using the name code when I goto the "Update" page, but i'm not sure how to add the "selected" field, that way what ever I saved in the database will load. Example: I goto add and it add's the "id" of 7 to the field, when I load the page again it auto's back to 1 instead of clicking in-to 7 as thats whats already there... = ) Code:
View Replies !
Dropdown Menu <selected Name="...
I have a dropdown menu like this one: <select name="country" tabindex="6" id="select_country"> <option value="">- Country List -</option> <?php $query = "SELECT * FROM country ORDER BY country ASC"; $result = mysql_query($query) or die('Error, query failed'); while ($row = mysql_fetch_array ($result)) { $country = $row['country']; ?> <option value="<?php echo $country ?>"><?php echo $country ?></option> After I have selected one country and I hit the submit button it go back to the default value in the box, what I want is to show the selected value in box until I selected another value. If the default value is Australia when I start this page, I then select USA and hit the submit button it reset to the default value "Australia", but I want it to show USA as long I not select anything else. I have tried to use session in selected="<?php echo $_SESSION['country']; ?>" but it didnt work.
View Replies !
Print All Selected Items From Dropdown??
I have a program that allows users to select a 'New Graduate' membership, and for each one selected, they get a free tshirt. I've got that working using a 'is_new_grad' function that I created. So, if they select 2, they see 2 dropdowns to select the sizes of them. It then sends an email w/ the membership info and the shirt sizes selected. However, when the email is being sent, it's only returning the size of the LAST item selected in from the drop-downs. Example: if I sign up for four of these memberships and select four different tshirt sizes (1 Medium, 1 Lg, 1 XL, and 1 XXL), the info in the email is all XXL: Code:
View Replies !
Dropdown List Selected By Default?
Does any one know how to have an item in the dropdown list selected by default? $city_field = HTML_QuickForm::createElement('autocomplete', 'city', 'City', $cities); $cities is an array of city names and I would like, say 'Los Angeles' selected by default.
View Replies !
How To Pass The Value Of Selected Dropdown Menu To Another File?
there is a php-myql script that list the mysql databases in the drop-down menu, use wil select one and the submit button should pass the value or variable $db_name to the test.php, this script list the databases in the drop-down menu but when i select one and then click on submit cannot pass the db_name to the test.php:
View Replies !
Dynamic Dropdown And Hardcode Dropdown In Select Form
I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add". But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: PHP Code:
View Replies !
Detect What Option The User Selected And Then Direct That User To The Selected Page.
Quick question regarding HTML forms and select fields. I want to be able to detect what option the user selected and then direct that user to the selected page. <select> <option name="1">1.html</option> <option name="2">2.html</option> </select> when the user selects, 1.html, it'll direct them to http://www.domain.com/1.html same with 2.html. I wasn't sure if this was done with PHP or Javascript, if its possible on both, which is better?
View Replies !
Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple selects in a list. When I click on a master record I have as part of my form the select statement for the multiple choice list. I want the list to highlight the multiple chosen values. here is part of the code. $dresscat = specdresscat($dresstypeid); //this is the query to get the values in the detail table $drcatrow = pg_fetch_array($dresscat);// the array for the detail table. <select name="stages[]" multiple="multiple"> <?php $allstages = allstages(); // this is a function to query my database to get the value for the list. while ($allstagerows=pg_fetch_array($allstages)) { $eachstage= $allstagerows["stageid"]; $specstage= $drcatrow["stageid"]; // this is the point I need help if ($specstage == $eachstage){ ?> <option value=<?php echo $eachstage;?> selected="selected"><?php echo allstagerows["stage"]?></option> <?php }else{ ?> <option value=<?php echo $eachstage;?>><?php echo $allstagerows["stage"]?></option> <?php } } ?> </select>
View Replies !
Remember Input Value
I have a form, after users submit it, if they leave the required fields blank, I need to let them go back to the page and fill those fields. How can I remember the values the users already filled so they don't need to fill the same fields again? Is there any other ways to do this except using cookie? Is there any 'forward' or 'redirect' function can do this?
View Replies !
Trying To Remember A Function's Name
I am drawing a total blank on this... I'm sure that I've seen it in javascript or PHP... I'm looking for a function that takes a variable (such as an array) and reduces it to a string which can be reconstituted. I remember that it does slightly more work than needed because all the types were specifically indicated even when they were self evident, but I can't remember the function's name. There is some unencoding function to go in reverse.
View Replies !
Option Value Remember
When a user clicks on a car the option box selects what car has been choosed, after filling the form in and if he has forgotten to type some info, the script echos what did he forget, and the prob is, that the option value disappears. How can i save the value or post it over? Code:
View Replies !
Remember On Login
my script www.myprofilepic.com runnin dolhpin 5.4 was wondering how i cud add the remember me feature on the login box,so when people close page and open it,they still remain logged in ':thumbsup:'
View Replies !
Remember A Member
I made a member system it works great but i want to make a posting area for my members. At the mo i just have a simple forum script so am adding it to my member system i have the auth working so it only lets members post. I just don't know how to allow my members to edit or delete a post. i know how to delete posts and edit them if you know what i mean it's just allowing the person who submits the post to edit or delete it? it would be really great if someone could show me as well as tell me how this could be done.
View Replies !
Remember Location
What would be the best way to remember a location on a map or something? Think of an RPG. When you come back, your location should be the same as when you logged off.
View Replies !
Remember User
I have a script where people can vote for a website, but I ony want people to vote once. I was using ip addresses to track that, but I found that ip addresses can change on a computer. Is there a better way to identify a person's computer without using cookies.
View Replies !
Remember Form Values
I have a form, and I'm using PHP to make sure the users filled in certain fields. If they haven't filled in a field, they are brought back to the form after submitting (using header location) and asked to fill it in. However, when they go back, the form values are all gone. How can I keep the form values there? I know i've seen it done, but I can't remember where.
View Replies !
Login Page: Remember ME
This is my 1st posting to this group. Can any1 help me with the "Remember Me" which is there in a login form. Im pasting the code below. Im not able to set a cookie.. <?php // saving script session_start(); displayLogin(); // connect to the server $conn= mysql_connect( 'localhost', 'csci242', 'spring2006' ) or die( "Error! Could not connect to database: " . mysql_error() ); // select the database mysql_select_db( 'blogtagz' ) or die( "Error! Could not select the database: " . mysql_error() ); // get the variables from the URL request string $uname = $_POST['uname']; $password = base64_encode($_POST['password']); $reme=$_POST['rememberme']; /** * checkLogin - Checks if the user has already previously * logged in, and a session with the user has already been * established. Also checks to see if user has been remembered. * If so, the database is queried to make sure of the user's * authenticity. Returns true if the user has logged in. */ function checkLogin(){ /* Check if user has been remembered */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){ $_SESSION['uname'] = $_COOKIE['cookname']; $_SESSION['password'] = $_COOKIE['cookpass']; } /* Username and password have been set */ if(isset($_SESSION['uname']) && isset($_SESSION['password'])){ //if(confirmUser($_SESSION['uname'], $_SESSION['password']) == 0){ /* Confirm that username and password are valid */ if(confirmUser($_SESSION['uname'], $_SESSION['password']) != 0){ /* Variables are incorrect, user not logged in */ unset($_SESSION['uname']); unset($_SESSION['password']); return false; } return true; } /* User not logged in */ else{ return false; } }
View Replies !
Session Remember Things It Should NOT....
I use sessions to store information in $_SESSION. However, variables that are not in $_SESSION that I define myself is also remember between pages in the same session. What gives? Is $error_msg a some kind of global variable? So, I might have two pages, let say page1.php and page2.php. They both use the variable $error_msg and session_start();
View Replies !
Remember Drop Down Box Selection
Is there a better way to do it than i currently am using? Simply echos the value in the selected option that will otherwise be blank, so this makes it impossible for the user to select no input. Code:
View Replies !
Adding A "Remember
I have a simple login script. I have the pages login.php login_response.php login_success.php login_failure.php What I want to do is have a checkbox on the login.php page where if the user checks it and logs in successfully, upon closing the browser and returning to the login.php page, they are automatically redirected to the login_success.php page. What must I do to accomplish this?
View Replies !
Remember Array Contents
i have the following code, that inserts the ID value of a link into an array, upon the link being clicked. See example link below: www.somthing.co.uk/functions.php?id=23 (www.somthing.co.uk/functions.php?id=23) How do I get the array to remember its contents, so if the browsers back button is used, and another link is clicked, this link should append/add it's id to whats already inside the array? Code:
View Replies !
Secure Way To 'remember' Users?
So far, for my site, there's an option for users to be 'remembered' when they login, so they don't have to login again on a second visit to the page, etc. You've seen those before, they're on all the big websites.. The first version included storing the user's name and id in a cookie, which was checked for at the top of every page. If the cookie was found, its data was exploded and put into $_SESSION. This was a really, really bad way to do it (since a user could just edit the cookie on their browser, imagine what'd happen if I'd stored 'access level' with the data), but I was young and stupid at the time. Code:
View Replies !
Sessions - Remember A User Is On The Site
I am building a members section for my site and I was curious what the best way to go about remember users would be. The site I'm working on is mainly an information site which will have the ability for people to login and view reviews on products and also allow manufacturers to login and upload information about their products. I was curious how I should remember a user is on my site. Currently, I have a $_SESSION[''] variable that remembers them but when they open a new browser it forgets them. Also this posses problems if they are still viewing my site but want to have 2 browsers open while on my site. Is this the best method? Also considering they login - they will have to relogin everytime they come back to my site. This makes me wonder if I should use cookies. I have never used them before. Would they be the best solution? Are they secure? Any information would be great.
View Replies !
PEAR::Auth 'REMEMBER ME' Feature
I use PEAR::Auth module to login my users. I noticed the lack of the 'remember me' feature (and the method 'setExpire' isn't enough). So I wonder HOW can I extend this package and provide the 'remember me' feature.
View Replies !
Remember Visited Links With Cookie
I've got a very simple, flat-file, private forum written in PHP for a dozen or so users. I want to be able to keep track of which messages have been read by each user using a cookie, so that visited links will persist regardless of browser settings. Of course I understand that if the cookie is deleted, that info will be lost. It's a low-usage forum so the total number of messages is low.
View Replies !
Remember Form Settings W/cookies
I have a sort script that i use to sort the results on a page. And the form sets a cookie and goes from there. It work all great. But the problem that i need to fix is remember the settings in the form. <form action ="list.php" method = "post"> View by: <select name="view"> <option value="title">Name</option> <option value="views">Popular</option> <option value="date">Newest</option> </select> Order by: <select name="order"> <option value="DESC">Descending</option> <option value="ASC">Ascending</option> </select><br /><br /> Per page: <select name="per"> <option value="1">1</option> <option value="2">2</option> <option value="5">5</option> </select> <input type="submit" name="sort" value=" Sort " /> </form> Now when you submit this form it will set a cookie with your "view", "order", and "per" selection. What i want it to do is after you set that cookie and come back to this form to have them settings remembered in the form. Basicly i guess add the selected="selected" to the option script in the form.
View Replies !
PHP Login Remember Username And Pass
I currently have a login to my website that works great BUT I would really like to have a cookie remember the username and password so next time the user wants to login they can simply just click login. I do not wish to have the system auto-log them in. If you want to take a look at my current login pages code let me know.
View Replies !
How Does VBulletin Remember The Page For Redirects?
I noticed that if you're not logged in and you try to reply to a thread, you can log in and it takes you right to the reply. It looks like the login form save the referring page, but how does it doe this? Does it rely fully on HTTP_REFERER or is there a backup plan if this doesn't work?
View Replies !
Looped Rows In Table Add & Remember Values
I'm trying to get this app to work. It's supossed to: 1. create rows dynamically through a loop (done) 2. remember the user-entered-values while the form posts to itself 3. provide a total (addition) of all 4 rows. (kinda tricky since the rows are looped). PHP Code:
View Replies !
Selected Value
Trying to get the below to have the SELECTED value chosen but it is not working. What am I doing wrong? while ( $buyerline= mysql_fetch_array($getresult, MYSQL_ASSOC)) { print "<option value='$buyerline[id]'".($buyerline[id]=='$buyer'?' SELECTED':'').">$buyerline[buyer]</option> "; } print '</select>'
View Replies !
$selected
I'm trying to generate a select box through php. the problem comes when I try to dynamically add in the 'selected' attribute to one of the options. My script is basically the following: Code: foreach($values as $key => $value) { if ($key == $checkVar) { $selected = ' SELECTED' } else { $selected = '' } $options .= '<option value="'.$key.'"'.$selected.'>'.$value.'</option>' } print '<select>'.$options.'</select>'
View Replies !
$_SESSION["varname"] Remember Value After Unset
I have a problem with a session variable: in my main php page I have the following code : session_start(); if (!isset($_SESSION["rndOrderNR"])) ... ... $_SESSION["rndOrderNR"]=rand(0, 999); This put a random number in the session variable. And if I do an unset from an include page like: unset($_SESSION["rndOrderNR"]); session_destroy(); it even clears the session variable. but when I run my main php again to calculate a new random number, it radomizes the same number?
View Replies !
Selected Box Action
how to set the respond to action when user choose an option inside a <select></select> box? eg. when user select an option in the <select> box then php search for data inside mysql and then display the required data on the <input type=text>.
View Replies !
Know Out Of All Checkboxes How Many R Selected And Which Are They?
i have a checkbox array of some unknown size.its a dynamic array created. i want to know out of all checkboxes how many r selected and which are they? and then insert the data in the table based on that. i hav written the code as follows:- <? $no=0; $friendname= $_POST['friendname']; $storecount=$_POST['storeid']; while($no<$storecount) { if($friendname[$no]) { $sql = "INSERT INTO groupfriends (groupid, username) VALUES ('$stid[$no]', '$friendname[$no]')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); } $no=$no+1; } ?> i dont think this will work.it will add all the checkoxes data to the table. i want to insert only of those which r selected.
View Replies !
Selected Combo Box
i have the following code and i am having problems with setting the combox to select the value that is stored in the database. i am hoping that the combo box selects the value and the value from the database is stored in $title PHP Code: <?php function displayedit($id,$title,$fn,$ln,$instit,$depart,$email,$url,$room,$phone) {Â Â echo ' Â Â <form name="editform" method="post" action="editform.php"> Â Â <p class="body"><b>Title:</b>' Â Â Â Â $t ="Dr","Professor","Mr", "Ms" Â Â Â Â echo "<select name='selectTitle'>"; Â Â Â Â foreach ($t as $value) { Â Â Â Â Â echo "<option value="$tvalue"";
View Replies !
No Database Selected
Im running twice the same website: - one for the public - one for private testing Everything is moreless the same, except some config variables in the php and the replacement of css directories. However on the test server im getting a no database selected: mysql_query('sqlhere') doesnt work mysql_query('sqlhere',$conn) does work So somehow on my test server it is not taking the only open connection, but wants it specified. Code:
View Replies !
Selected In A Drop Down
I have two drop down menus. First one is location. When you change location page refreshes and comes with the selected area. So with the refresh,the second drop down changes to the sub-locations of the selected location. For example: Here is my code: <?php if ( ! isset($location) ) { $location="Bodrum"; } @mysql_connect ( "localhost", "root", "passwd" ) || die ("MySQL'e baglanamadim"); mysql_select_db ( "ceyhun" ) || die ("Veritabanýný seçemedim"); $sorgu=mysql_query("Select *from locations"); $sorgu2=mysql_query("Select *from sublocations where Location='$location'"); ?> ........
View Replies !
|