Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: refreshing page

  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    refreshing page

    hey guys... ok i want to refresh my page so when the form is submited it just refreshes the page... i thought about doing this

    PHP Code:
    <link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"><?php session_start(); 



    ?>
    <style type="text/css">
    <!--
    .message {
    color: #000000;
    font-family: Verdana;
    font-size: 10px;}

    .username {
    color: #FF9900
    font-family: Verdana;
    font-size: 4px;
    font-weight: bold}

    .date {
    color: #707070;
    font-family: Verdana;
    font-size: 2px;}
    -->
    </style>
    </head>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="padding: 2px">
    <?php 

    //echo $user; this displays the user name but anything below it does not
    if($_POST['submit']) {
     
    // Verify if the fields were filled.
    if(!$_POST['message']) {
    echo 
    'Error, You need to post a Message!';
    die;
    }
     
    // Date format
     
    $date date("d/m/y"); // http://www.php.net/date
     
    // Assign variables of the forms
    // Connect to the database
     
    include('../settings.php');
    $user $_POST['username']; 
    $id $_SESSION['user_id'];
    $username get_username($id);
    $message $_POST['message'];
    $ip $_SERVER['REMOTE_ADDR'];
     
     
     
     
     
    // Insert the info in the shoutbox table.
    $query "INSERT INTO shoutbox (`user`, username, message, date, ip)
    VALUES ('$user','$username','$message','$date','$ip')"
    ;
    mysql_query($query);
    // close connection
     
     
    // Show message to let them return to the shoutbox
    ?>
    <div align="center">Thank you for submitting.<br>
    Return to the <a href="shoutbox.php">shoutbox</a>!
    <?php
    // If NOT submitted
    } else {
     
     
     
     
    $user2 $_GET['username'];
    $query "SELECT * FROM shoutbox WHERE user = '$user2' ORDER BY id DESC LIMIT 3";
    $result mysql_query($query);
    // Create a table
    ?>
     
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
     
    <?
    // Run a While loop for the rows
    while($c mysql_fetch_array($result))
    {
    ?>
    <tr>
    <td>
    <?php echo $c['username']; ?> says:
    <div align="justify"><?php echo $c['message']; ?></div>
    </td>
    </tr>
    <tr><td>on <?php echo $c['date']; ?>
    <hr noshade="noshade" size="1" style="border-style: dashed" color="#000000" /></td></tr>
    <? ?>
     
    </table>
     <?php $user1 $_GET['username'];?>
    <form method="post" action="<?php echo $user1;?>">

    <input type=hidden name=username value='<?php echo $user1;?>'>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td>Message :</td>
    <td> <input type="text" name="message" class="input"></td>
    </tr>
    <tr>
    <td colspan="2"><input name="submitButtonName" type="submit" class="submit-btn" value=""></td>
    </tr>
    </table>
    </form>
     
    <?php ?>
     
    </body>
    </html>
    but the problem is as its included on my profile.php it then does not insert the data into the database... so has any1 got any better ideas on how to do this it would be good to have it like facebook where it says posting then posted and refreshes the message are...is this done by iframes>
    Last edited by runnerjp; 05-15-2008 at 03:37 PM.

  • #2
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    I read your post several times and I still can't figure out what you're asking. I really hate to say it, but could you repost your problem in more detail... using punctuation? I'm more than sure I could fix the problem, I just don't really know what results you're looking for. What I understand is:

    You want to click submit, it submits the data, then it brings you back to the same page except without resubmitting the data? What's this about it being included by another file?

    Also, this is really dangerous:
    Code:
     $user2 = $_GET['username'];
    $query = "SELECT * FROM shoutbox WHERE user = '$user2' ORDER BY id DESC LIMIT 3";
    I suggest using mysql_real_string_escape on $_GET['username'] to prevent any SQL injection.

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    ok so i have profile.php

    which has users image name ect... and on this i have included box.php

    box.php is the script you see above... what i want to do is refresh box.php on the profile.php page so when a message is posted it is shown instantly on profile.php... does that makes sence??

    and ty on heads up on mysql_real_string_escape


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •