rallokkcaz Posted April 26, 2007 Share Posted April 26, 2007 i have a page called update.php which updates the users profile the code for the page is this <? session_start(); require '../config.php'; $fullname = $POST_['fullname']; $password = $POST_['password']; $aboutme = $POST_['aboutme']; $email = $POST_['email']; $query = "UPDATE users SET fullname='$fullname', password='$password', aboutme='$aboutme', email='$email' where id='{$_SESSION['id']}'"; mysql_query($query) or die('Error, query failed'); header("Refresh: 2; url=../edit_profile"); echo "Updating Profile..."; ?> and the code for the edit_profile is here: <?php session_start(); //include config.php file include('../config.php'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <style> .words { background-color:#16333B; color:#A9D033; } </style> <?php $p=$_GET['p']; //see my ?id= browsing tutorial switch($p){ default: //if user isn't logged in lets show him the log in form if(!isset($_SESSION['username'])){ ?> <form action='../login.php' method='POST'> You Must Be logged in to View this page!<br> Login here:<br> Username: <input type='text' name='username' class='words'><br> Password: <input type='password' name='password' class='words'><br> <input name='login' type='submit' value='Submit' class='words'><br> Not <a href="../register.php">registered</a>? </form> <?} else{ //$_SESSION['username'] = the current users //username. It will be echoed like "Hi, user!" echo <<< HTMLFORM <form action="../edit_profile/update.php" method="post"> <table cellpadding="2" cellspacing="1" width="400"> <tr> <td wdith="35%">Username:</td> <td>{$_SESSION['username']}</td> </tr> <tr> <td>Full Name:</td> <td><input type="text" name="fullname" value="{$user['fullname']}" /></td> </tr><tr> <td>Password:</td> <td> <input type="password" name="password" value="" /></td> </tr> <tr> <td>About Me:</td> <td><textarea height="200px" width="300px" input type="text/html" name="aboutme" value="" />{$_SESSION['aboutme']}</textarea></td> </tr><tr <tr> <td>Email Address:</td> <td><input type="text" name="email" value="" /></td> </tr> <tr> <td colspan="2"> <input type="hidden" name="id" value="{$_SESSION['id']}" /> <input type="submit" name="update" value="Update Profile" > </td> </tr> </table> </form> HTMLFORM; } } ?> when you click the submit button nothing updates can anyone help me? Quote Link to comment Share on other sites More sharing options...
john010117 Posted April 26, 2007 Share Posted April 26, 2007 You put the "?>" after "if(!isset($_SESSION['username'])){". Not sure why you did that. That's why the rest of the code is not processing. Put echo instead. Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 k i'll try fixing that Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 ok that didn't do anything nothing updates ive been trying this for 2 days and i can't figure out what im doing wrong ??? ??? Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 anyone?!? :-\ :-\ Quote Link to comment Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 UM yeah! See how you have <?} .. bound to cause a syntax error. Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 i fixed that <?php session_start(); //include config.php file include('../config.php'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <style> .words { background-color:#16333B; color:#A9D033; } </style> <?php $p=$_GET['p']; //see my ?id= browsing tutorial switch($p){ default: //if user isn't logged in lets show him the log in form if(!isset($_SESSION['username'])){ echo <<< HTMLFORM <form action='../login.php' method='POST'> You Must Be logged in to View this page!<br> Login here:<br> Username: <input type='text' name='username' class='words'><br> Password: <input type='password' name='password' class='words'><br> <input name='login' type='submit' value='Submit' class='words'><br> Not <a href="../register.php">registered</a>? </form> HTMLFORM; }else{ //$_SESSION['username'] = the current users //username. It will be echoed like "Hi, user!" echo <<< HTMLFORM <form action="../edit_profile/update.php" method="post"> <table cellpadding="2" cellspacing="1" width="400"> <tr> <td wdith="35%">Username:</td> <td>{$_SESSION['username']}</td> </tr> <tr> <td>Full Name:</td> <td><input type="text" name="fullname" value="{$user['fullname']}" /></td> </tr><tr> <td>Password:</td> <td> <input type="password" name="password" value="" /></td> </tr> <tr> <td>About Me:</td> <td><textarea height="200px" width="300px" input type="text/html" name="aboutme" value="" />{$_SESSION['aboutme']}</textarea></td> </tr><tr <tr> <td>Email Address:</td> <td><input type="text" name="email" value="{$_SESSION['email']}" /></td> </tr> <tr> <td colspan="2"> <input type="hidden" name="id" value="{$_SESSION['id']}" /> <input type="submit" name="update" value="Update Profile" > </td> </tr> </table> </form> HTMLFORM; } } ?> the thing is with this is that i get no errors it just doesn't work Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 26, 2007 Share Posted April 26, 2007 does it take you to a different page on form submit? if it does, view the source of the document to see what is getting to the browser. my guess is you've got the wrong path to the wrong document. header("Refresh: 2; url=../edit_profile"); that's only calling for a directory. do you have an index.php in there? is that where you want it to go? also, i think this is unecessary: <input type="hidden" name="id" value="{$_SESSION['id']}" /> it's stored in a session, so you don't have to store the data into hidden input fields. unless i'm missing something. Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 does it take you to a different page on form submit? if it does, view the source of the document to see what is getting to the browser. my guess is you've got the wrong path to the wrong document. header("Refresh: 2; url=../edit_profile"); that's only calling for a directory. do you have an index.php in there? is that where you want it to go? also, i think this is unecessary: <input type="hidden" name="id" value="{$_SESSION['id']}" /> it's stored in a session, so you don't have to store the data into hidden input fields. unless i'm missing something. its calling for the directory because that is the page with the editprofile form and it doesn't go to a directory it goes to a page Quote Link to comment Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 Yeah, actually you are. Keeping them in hidden fields makes people who try and externally modify forms unable to without automatically having to insert a session id, thus keeping away most people who try and do evil stuff like that. As to the other guy, you should probably try keeping all this kind of stuff on one file. I find it much easier to look at myself. If theres more than one pages code worth in there, you mind putting them into seperate code boxes? Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 ive tried that it still doesn't work <thinks-to-self>this is becoming quite frustrating<thinks-to-self> i have absolutly no idea what could not be working Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 26, 2007 Author Share Posted April 26, 2007 i think im just gonna restart and make an new file because the one i have doesn't seem to work can someone show me how i would make a form that updates the database?? Quote Link to comment Share on other sites More sharing options...
sw0o0sh Posted April 26, 2007 Share Posted April 26, 2007 No you didnt >_> I dont see a code exerpt of every page inserted and carefully named for my easy reading Btw, dont get UPDATE and insert mixed up. If you want them to register, then you'll use INSERT, you want them to modify their profile, youd be using UPDATE. I have no CLUE how your form processing php code works if you arent showing it to me. All I see is code exerpts of forms and actions of forms that goes to pages you dont show the source of. Quote Link to comment 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.