-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
good thinking darkwater, i didin't even look for that
-
it still changes it
-
with this code
} if(isset($_POST['hideemail']) == 0) { mysql_query("UPDATE $user SET show_email = '0' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } elseif(isset($_POST['hideemail']) == 1) { mysql_query("UPDATE $user SET show_email = '1' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } echo "Settings Saved"; }
its changing the show_email even when i don't tick either box, it shouldn't be doing this, it should only do this if it is ticked.
-
erm, it doesn't make sense why it isn't.
-
thanks , although mine wasn't far off
-
are there any errors, and change the code to this.
<?php $company = $_POST['company']; $name = $_POST['name']; $city = $_POST['address']; $postal = $_POST['postal']; $tel = $_POST['tel']; $email = $_POST['email']; $comments = $_POST['comments']; if(isset($_POST['submit'])) { echo "$company<br>$name<br>$city<br>$postal<br>$tel<br>$emaili<br>$comments"; // add anything you want displayed } else { ?> <u>Input a user</u> <br /> <form method="post" action='<?php $_SERVER['PHP_SELF']; ?>'> <table> <tr> <td>Company: <td><input type="text" name="company"> </tr> <tr> <td>Name: <td><input type="text" name="name"> </tr> <tr> <td>Address: <td><input type="text" name="address"> </tr> <tr> <td>City: <td><input type="text" name="city"> </tr> <tr> <td>Postal Address: <td><input type="text" name="postal"> </tr> <tr> <td>Telephone Number: <td><input type="text" name="tel"> </tr> <tr> <td>Email Address: <td><input type="text" name="email"> </tr> <tr> <td>Comments: <td><input type="text" name="comments"> </tr> <tr> <td><input type="submit" value="Submit"> </tr> </table> <?php } ?>
first of all and once this bit works, work on the search.
-
ok, let me change the code a bit
<?php $company = $_POST['company'] $name = $_POST['name'] $city = $_POST['address'] $postal = $_POST['postal] $tel = $_POST['tel'] $email = $_POST['email'] $comments = $_POST['comments'] if(isset($_POST['submit'])) { echo $company<br>$name<br>$city<br>$postal<br>$tel<br>$email<br>$comments; // add anything you want displayed } else { ?> <html> <body> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='POST'> <table> <tr> <td>Company: <td><input type="text" name="company"> </tr> <tr> <td>Name: <td><input type="text" name="name"> </tr> <tr> <td>Address: <td><input type="text" name="address"> </tr> <tr> <td>City: <td><input type="text" name="city"> </tr> <tr> <td>Postal Address: <td><input type="text" name="postal"> </tr> <tr> <td>Telephone Number: <td><input type="text" name="tel"> </tr> <tr> <td>Email Address: <td><input type="text" name="email"> </tr> <tr> <td>Comments: <td><input type="text" name="comments"> </tr> <tr> <td><input type='submit' value='Submit' name='submit' /> </tr> </table> <?php } ?>
-
if(isset($_POST['update'])) { if($user_email) { if($user_email == $user_email2) { mysql_query("UPDATE $user SET user_email = '$user_email' WHERE user_id = '$user_id'")or die('Could not update email: ' . mysql_error()); } else { echo "Email Addresses do not match"; } } if($user_password) { if($user_password == $user_password2) { mysql_query("UPDATE $user SET user_password = '$user_password' WHERE user_id = '$user_id'")or die('Could not change password: ' . mysql_error()); } else { echo "Passwords do not match"; } } if(isset($_POST['hideemail'])) { mysql_query("UPDATE $user SET show_email = '0' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } elseif(isset($_POST['hideemail'])) { mysql_query("UPDATE $user SET show_email = '1' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } } ?> <html> <table bgcolor='#999999' align='center' width="400px"> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='POST'> <tr><td width="10px">Maximum Length<br /> 20 characters.</td></tr> <tr><td width="10px">E-mail Address:</td> <td><input type='text' name='user_email' value="<?php echo "$email"; ?>" /><br /></td></tr> <tr><td width="10px">Confirm E-mail Address: </td><td><input type='text' name='user_email2' value="<?php echo "$email"; ?>" /><br /></td></tr> <tr><td width="10px">Maximum Length<br /> 30 characters.</td></tr> <tr><td width="10px">New Password:</td><td> <input type='password' name='user_password' maxlength="30" /><br /></td></tr> <tr><td width="10px">Confirm Password:</td><td> <input type='password' name='user_password2' maxlength="30" /><br /></td></tr> <tr><td width="10px">Hide Email</td><td width="10px">Yes<input type="radio" value="0" name="hideemail"/> No<input type="radio" value="1" name="hideemail"/> </td></tr> <tr><td><input type='submit' value='Save Changes' name='update' /></td> </form> </table> </html>
this is my code for the page where they can check the box, i want it so that if they check one it updates the database and if another updates it differently
-
so if im right? you want to display what they enter in the form on the page, try this
<?php $array = array("company","name","address","city","postal","tel","email","comments"); // i've never used arrays so im not sure if this way works if(isset($_POST['submit'])) { echo $array["company"]; // add anything you want displayed } else { ?> <html> <body> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='POST'> <table> <tr> <td>Company: <td><input type="text" name="company"> </tr> <tr> <td>Name: <td><input type="text" name="name"> </tr> <tr> <td>Address: <td><input type="text" name="address"> </tr> <tr> <td>City: <td><input type="text" name="city"> </tr> <tr> <td>Postal Address: <td><input type="text" name="postal"> </tr> <tr> <td>Telephone Number: <td><input type="text" name="tel"> </tr> <tr> <td>Email Address: <td><input type="text" name="email"> </tr> <tr> <td>Comments: <td><input type="text" name="comments"> </tr> <tr> <td><input type='submit' value='Submit' name='submit' /> </tr> </table> <?php } ?>
-
in case the title didn't make sense , i will explain.
how can i have it so if a user checks a box it stays checked and if they don't check it , it isn't checked??
also is there a way to have multiple check boxes with the same, but then how can i differ them when using an if(isset($_POST['']))
function as they have the same name(how else can they be intetifed)
-
o rite, so WHERE is what row?
-
so would this be right, to edit details for this getting the row from there id no.
$user_id = $_SESSION['user_id']; mysql_query("UPDATE SET user_id = '$user_id' WHERE user_name = $user_name AND user_password = $user_password AND user_email = $user_email")
-
how can i insert into a certain row in my database
mysql_query("INSERT INTO `$user` (user_name, user_password, user_email) VALUES ('$user_name','$userPswd','$user_email')")
this is the code, i want to use there user_id and/or there user_name to find the row to insert into
-
o yer, soz my fault, i thought i had tried it with that added.
Thanks for all the help.
-
no, db_connect.php has the session_start() on it also when i try to echo like this
<?php require_once 'db_connect.php'; require_once 'nav_bar.php'; require_once 'logged_in.php'; $user_id = $_SESSION['user_id']; $sql = "SELECT * FROM $user WHERE `user_id`='{$user_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $username = $row['user_name'] echo "$username"; ?>
i get an "unexpected" error with this, it doesn't expect the echo
-
this code is right but, it doesn't display anything from the database
<?php require_once 'db_connect.php'; require_once 'nav_bar.php'; require_once 'logged_in.php'; $user_id = addslashes($_GET['id']); $sql = "SELECT * FROM `$user` WHERE `user_id`='{$user_id}' LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $username = $row['user_name'] ?>
i tried changing it to this but, it still isn't displaying anything
<?php require_once 'db_connect.php'; require_once 'nav_bar.php'; require_once 'logged_in.php'; $user_id = $_SESSION['user_id']; $sql = "SELECT * FROM $user WHERE `user_id`='{$user_id}' LIMIT 0,1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $username = $row['user_name'] ?>
do i need to echo it?
-
i get this error
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/deanwhitehouse.awardspace.co.uk/test/user_profile.php on line 9
with this code
<?php require_once 'db_connect.php'; require_once 'nav_bar.php'; require_once 'logged_in.php'; $user_id = addslashes($_GET['id']); $sql = "SELECT * FROM `$user` WHERE `id`='{$user_id}' LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $username = $row['user_name'] ?>
-
how would i arrange this data
-
i have this code for the user profile link
<a href='user_profile.php?id=<?php echo $_SESSION['user_id']; ?>'>Settings</a><br>
now on the user_profile.php page how do i display this users profile, can i call all there details from the database using there user_id
-
how do i do the issest check as i only no how to do it for $_POST
i no
if (isset($_POST['login'])){
but how can i make it work for me
-
i think its the right title, anyhow
how can i make a login code so the link is like
<a href="whateverpageon?logout">Logout</a>
instead of my
<a href="logout.php">Logout</a>
basically ,so that when they logout they are kept on the same page
-
soz, add session_start() at the beggining of it
-
session_unset();
session_destroy();
logout
-
try this
<?php session_start(); if ($_SESSION['logged_in'] == true){ echo "You are logged in."; } else { echo "You are not logged in."; } ?>
and this
<?php session_start(); $username = "lemon"; $password = "123"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> <form name="login" method="post" action="<?=$_SERVER['PHP_SELF']; ?>"> <table> <tr><td>Username: <td><input type="text" title="Enter your Username" name="txtUsername" /> <tr><td>Password: <td><input type="password" title="Enter your password" name="txtPassword" /> <tr><td colspan=2 align=right><input type="submit" name="Submit" value="Login" /> </table> </form> <?php } else { $_SESSION['logged_in'] == true; echo "Hello "; echo "$username"; echo ".<br>You will be redirected to the admin page in a couple of seconds..."; ?> <META http-equiv="refresh" content="2;URL=/admin/"> <?php } ?>
[SOLVED] check box, problem 2
in PHP Coding Help
Posted
i still have the same problem