quickstopman Posted June 13, 2007 Share Posted June 13, 2007 hey guys i have edit profile page for the user the issue is that some of the values use <select> and when the user refreshes the page the <select> box changes back to the first value and instead i want it too stay on the select value here is the code $id = $_SESSION['userid']; if (isset($_SESSION['userid'])) { $sql = mysql_query("SELECT * FROM users WHERE userid = '{$id}'") or die(mysql_error()); $r=mysql_fetch_array($sql); $knickname = $_POST['nickname']; $state = $_POST['state']; $age = $_POST['age']; $email = $_POST['email']; $country = $_POST['country']; $states = file("states.txt"); sort($states); if ($_POST['submit']) { $result = mysql_query("UPDATE users SET `knickname` = '$knickname', `age` = '$age', `email` = '$email', `state` = '$state', `country` = '$country' WHERE userid = '$id'") or die(mysql_error()); header ("Refresh:2"); echo "Your profile has been Updated<br>"; } else { ?> <form method="POST"> Knickname: <input name="nickname" type="text" value="<? echo $r['knickname']; ?>"><br> Age: <select name="age"> <? for ($i = 1; $i < 105; $i++) { echo "<option>". $i ."</option>"; } ?> </select> Current age <? echo $r['age']; ?><br> State: <select name="state"> <? foreach ($states as $state) { echo "<option>". $state ."</option>"; } ?> </select><br> Country: <input name="country" type="text" value="<? echo $r['country']; ?>"><br> Email: <input name="email" type="text" value="<? echo $r['email']; ?>"><br> <input type="submit" name="submit" value="Submit"> </form> <? } } else { header ("Location:index.php?action=login&message=login"); } any ideas Quote Link to comment https://forums.phpfreaks.com/topic/55445-selected-help/ Share on other sites More sharing options...
trq Posted June 13, 2007 Share Posted June 13, 2007 There isn't anything php can do here. If the page hhasn't been submitted, php never sees the values. Maybe your looking for a Javascript solution. Quote Link to comment https://forums.phpfreaks.com/topic/55445-selected-help/#findComment-274015 Share on other sites More sharing options...
quickstopman Posted June 13, 2007 Author Share Posted June 13, 2007 it probly is but i have no idea how to do that since im horrible at Javascript what do you think would work? Quote Link to comment https://forums.phpfreaks.com/topic/55445-selected-help/#findComment-274020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.