Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/48722-updatephp-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/48722-updatephp-help/#findComment-238779
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/48722-updatephp-help/#findComment-238780
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/48722-updatephp-help/#findComment-238783
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/48722-updatephp-help/#findComment-238784
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/48722-updatephp-help/#findComment-238795
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.