Jump to content

This isn't working


Colourtheory

Recommended Posts

No error is coming up, but it doesn't change the value.

<?phprequire_once 'db.php';$page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : ''; if ($page_mode == 'setbio'){ $id = $_SESSION['id'];$find = mysql_query("SELECT bio FROM users WHERE id='$id'");$bio = mysql_fetch_assoc($find);$biotext = $_GET['bio'];$update = db_query("UPDATE users SET bio='$biotext'WHERE id='$id'");  } ?><?php session_start();     if (isset($_SESSION['user_id'])){?><h1>Customize your profile, <?php echo "" . $_SESSION['user_name'] . "!"; ?><br><form action="myprofile.php" method="post"><input type="hidden" name="page_mode" value="setbio"><input type="text" text="Bio" name="bio"><br><input type="submit" name="submit"></form><?php} else{header('Location: login.php');     } ?>

Link to comment
Share on other sites

what value are expecting to show up? What error reporting do you have turned on? if not set within php.ini, at the very least you should have this at the top of your script

 error_reporting(E_ALL);ini_set('display_errors', '1');

it looks like in the if condition that if you are expecting $_POST['page_mode'] to be set, and then $page_mode to be equal to 'setbio', you are also assuming $_SESSION[''id'] to be set without actually calling session_start(). Is this the use case you are experiencing?

Edited by thescientist
Link to comment
Share on other sites

at the start in php you are checking for $_POST['page_mode'] and if it is not set then ypur are assigning it as a value = ' ' (null/blank) instead of this i wold like suggest if(isset($_POST['$page_mode'])){ $page_mode == $_POST['$page_mode'];if ($page_mode == 'setbio'){ $id = $_SESSION['id'];$find = mysql_query("SELECT bio FROM users WHERE id='$id'");$bio = mysql_fetch_assoc($find);$biotext = $_GET['bio'];$update = db_query("UPDATE users SET bio='$biotext'WHERE id='$id'");}} and check your code by adding echo in each if as well as else loop.. you will get your answer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...