Jump to content
Sign in to follow this  
Colourtheory

This isn't working

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');     } ?>

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...