rallokkcaz Posted April 26, 2007 Share Posted April 26, 2007 im currently working on this update form (it hasn't been working for 3 days now) and now im getting this error in the code Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/pokebash/public_html/getmetola/edit_profile/default.html on line 76 here is the code <?php ob_start(); 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> //line 30 HTMLFORM; }else{ //$_SESSION['username'] = the current users //username. It will be echoed like "Hi, user!" echo <<< HTMLFORM <form name="update" 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="{$_SESSION['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> //line 60 </tr> <tr> <td colspan="2"> <input type="submit" name="update" value="Update Profile" > </td> </tr> </table> </form> HTMLFORM; ///variables... $update = $_POST['update']; $fullname = $_POST['fullname']; $password = md5($_POST['password']); $aboutme = $_POST['aboutme']; $email = $_POST['email']; //if button is pressed if ($_POST['update']){ $sql= "update users set fullname='$fullname', aboutme='$aboutme' where id='$_SESSION['id']'"; mysql_query($sql) or die(mysql_error()); header(Refresh: 2); echo "Congratulations! Yout Profile is Updated<br> } else { header(Refresh: 2); echo "Your Profile didn't Update"; ?> does any one know how to fix that? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 26, 2007 Share Posted April 26, 2007 theirs a ton of errors here the last part fixed ( well kinda) if ($_POST['update']){ $sql= "update users set fullname='$fullname', aboutme='$aboutme' where id='{$_SESSION['id']}'"; mysql_query($sql) or die(mysql_error()); header(Refresh: 2); //<<--you have already send data to the page echo "Congratulations! Yout Profile is Updated<br>"; } else { header(Refresh: 2);//<<--you have already send data to the page echo "Your Profile didn't Update"; } ?> recommend a re-write Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 27, 2007 Author Share Posted April 27, 2007 ok here is the form without errors i have no idea what im doing wrong but its not updating <?php ob_start(); 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{ ///variables... $update = $_POST['update']; $fullname = $_POST['fullname']; $password = md5($_POST['password']); $aboutme = $_POST['aboutme']; $email = $_POST['email']; $id = $_SESSION['id']; //if button is pressed if ($update) { // Get Sandy's record from the "example" table $result = mysql_query("UPDATE users SET fullname='$fullname', password='$password', aboutme='$aboutme', email='$email' WHERE id='$id'") or die(mysql_error()); header("Refresh:2"); echo "Profile Updated"; } else { //$_SESSION['username'] = the current users //username. It will be echoed like "Hi, user!" echo <<< HTMLFORM <form name="update" action="{$_SERVER['PHP_SELF']}" 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="{$_SESSION['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="submit" name="update" value="Update Profile" > </td> </tr> </table> </form> HTMLFORM; } } } ?> pleeze can someone tell me what im doing wrong!! ive been trying this for 3 days :( Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 27, 2007 Share Posted April 27, 2007 If line 76 is the last line, you might want to notice that - as posted - the script fails to close the final else { look. Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 27, 2007 Author Share Posted April 27, 2007 it closed i get no error's which is really odd it just doesn't update do you think it might have to do with the WHERE id='$id'" because i don't really understand what that does Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 27, 2007 Author Share Posted April 27, 2007 anyone Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 27, 2007 Author Share Posted April 27, 2007 can someone be a nice person and make a simple update form script for me because im way too much of a noob to do this Quote Link to comment Share on other sites More sharing options...
sanfly Posted April 27, 2007 Share Posted April 27, 2007 This is more or less how I would do it, keeping as much to your old script as possible. Regarding your old script, I couldnt work out why you were using the switch in there? Anyway.... Please note I have left a space where you need to update the session values after the insert <?php ob_start(); 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 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> <?php exit(); } else{ if($_POST['update']){ // Get Posted Variables... $fullname = $_POST['fullname']; $password = md5($_POST['password']); $aboutme = $_POST['aboutme']; $email = $_POST['email']; $id = $_SESSION['id']; // Get Sandy's record from the "example" table $result = mysql_query("UPDATE users SET fullname = '$fullname', password = '$password', aboutme = '$aboutme', email = '$email' WHERE id = '$id'") or die(mysql_error()); // wILL NEED TO UPDATE THE SESSION VALUES HERE echo "<B>Profile Updated</B><br><br>"; ?> <form name="update" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <table cellpadding="2" cellspacing="1" width="400"> <tr> <td wdith="35%">Username:</td> <td><?php echo $_SESSION['username']; ?></td> </tr> <tr> <td>Full Name:</td> <td><input type="text" name="fullname" value="<?php echo $_SESSION['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="" /><?php echo $_SESSION['aboutme']; ?></textarea></td> </tr> <tr> <td>Email Address:</td> <td><input type="text" name="email" value="<?php echo $_SESSION['email']; ?>" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="update" value="Update Profile" ></td> </tr> </table> </form> <? } ?> Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 27, 2007 Author Share Posted April 27, 2007 how do i update the session values? Quote Link to comment Share on other sites More sharing options...
rallokkcaz Posted April 27, 2007 Author Share Posted April 27, 2007 aww screw this > > its been just about 4 days and no luck.. well thanks for all the help Quote Link to comment Share on other sites More sharing options...
sanfly Posted April 27, 2007 Share Posted April 27, 2007 how do i update the session values? <? $_SESSION['username'] = $_POST['username']; ?> etc.... 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.