Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Posts posted by DeanWhitehouse

  1. 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.

     

  2. 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.

     

  3. 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
    }
    ?>
    

  4. 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

  5. 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
    }
    ?>
    

  6. 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)

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

  8. 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?

  9. 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']
    
    ?>

  10. 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

  11. 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

     

  12. 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
    }
    ?> 
    

×
×
  • 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.