PRodgers4284 Posted February 8, 2008 Share Posted February 8, 2008 I have a form on my website that displays user details once they have logged in, the form posts back what the user entered in at registration and allows them to update their account. I have added a textarea option to allow users to add additional information to their account, i cant same to get the textarea option to update the database. Here is my code: <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $update = mysql_query("UPDATE users SET username='" . $_POST["username"] . "',forename='" . $_POST["forename"] . "',surname='" . $_POST["surname"] . "',email='" . $_POST["email"] . "',mobile='" . $_POST["mobile"] . "',dob='" . $_POST["dob"] . "',location='" . $_POST["location"] . "',about='" . $_POST["about"] . "' WHERE username='" . $_SESSION["username"] . "'"); ?> <br /> <a href=\"index.php\">Back to main page</a> <br /> <br /> <br /> You have successfully updated your account . <?php } else { $account = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username='" . $_SESSION["username"] . "'")); ?> <form method="post" class="registerform" action=""> <fieldset> <label for="username">Your Account details</label><p><label for="username">Username:</label> <input name="username" type="text" id="username" value="<?php echo $account["username"]; ?>" /><br /> </p> </fieldset> <fieldset> <label for="forename">Forename:</label> <input name="forename" type="text" id="forename" value="<?php echo $account["forename"]; ?>" /><br /> </fieldset> <fieldset> <label for="surname">Surname:</label> <input name="surname" type="text" id="surname" value="<?php echo $account["surname"]; ?>" /><br /> </fieldset> <fieldset> <label for="email">Email:</label> <input name="email" type="text" id="email" value="<?php echo $account["email"]; ?>" /><br /> </fieldset> <fieldset> <label for="mobile">Mobile:</label> <input name="mobile" type="text" id="mobile" value="<?php echo $account["mobile"]; ?>" /><br /> </fieldset> <fieldset> <label for="dob">DOB:</label> <input name="dob" type="text" id="dob" value="<?php echo $account["dob"]; ?>" /><br /> </fieldset> <fieldset> <label for="location">Location:</label> <p></p> <select name="location"> <option value="Please Select">Please Select</option> <?php $location_opts = array( "Co.Antrim", "Co.Armagh", "Co.Down", "Co.Fermanagh", "Co.Londonderry", "Co.Tyrone", ); foreach($location_opts as $opt){ $selected = ($account["location"]) == $opt ? " selected=true":""; echo "<option value=\"" . $opt . "\"" . $selected . ">" . $opt . "</option>"; } ?> </select> </fieldset> <hr class="hr_blue"/> <fieldset> Additional Information<br /> <p></p> <fieldset> <label for="about">About you</label> <textarea></textarea> <p></p> <fieldset> <br /> <br /> <p class="submit"> <input type="submit" name="submit" value="Submit" /> </p> </fieldset> </form> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/ Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 If i'm not mistaken you haven't given the textarea html tag a "name=" attribute, hence looking for $_POST['about'] is always going to be an undefined index. Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/#findComment-461641 Share on other sites More sharing options...
PRodgers4284 Posted February 8, 2008 Author Share Posted February 8, 2008 If i'm not mistaken you haven't given the textarea html tag a "name=" attribute, hence looking for $_POST['about'] is always going to be an undefined index. Sorted, thanks for that Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/#findComment-461645 Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 Not a problem, i remember smacking my head on a desk for days over these sorts of things. print_r($_POST) is your friend Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/#findComment-461649 Share on other sites More sharing options...
PRodgers4284 Posted February 8, 2008 Author Share Posted February 8, 2008 Not a problem, i remember smacking my head on a desk for days over these sorts of things. print_r($_POST) is your friend I cant get it to post the value of the textarea back to the form so it can be updated, just appears blank. Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/#findComment-461656 Share on other sites More sharing options...
aschk Posted February 8, 2008 Share Posted February 8, 2008 I'm assuming your textarea looks like this now : <textarea name="about"></textarea> And when you fill it in and POST (to the same page) it's not updating your SQL table? Have you done print_r($_POST) to see what's coming through? Also what about "echo $sql;" to echo out your SQL statement and see what it's inserting/updating. Because you're posting back i'm guessing you want it to fill in the textarea with what you just posted? So i'm assuming your textarea probably looks like this now: <textarea name="about"><?php echo $account['about']?></textarea> This is assuming of course your select statement works... Let me know. Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/#findComment-461667 Share on other sites More sharing options...
PRodgers4284 Posted February 8, 2008 Author Share Posted February 8, 2008 I got everythin sorted, thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/90039-solved-textarea-form-problem/#findComment-461692 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.