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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: Problem

  1. #1
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem

    Shed Dont Post Email .. Name .. Date .. Time !! and im refresh page

    PHP Code:
    <?php
    /**
    CREATE TABLE `postwall` (
    `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `name` VARCHAR( 40 ) NOT NULL ,
    `email` VARCHAR( 40 ) NOT NULL ,
    `message` TEXT NOT NULL ,
    `date` DATE NOT NULL ,
    `time` TIME NOT NULL
    ) ENGINE = MYISAM ;
    **/

    echo "<h1>Wall Post</h1>";
    echo 
    "<hr>";
    //VARiable
    define('SER_NAME','localhost');
    define('SER_USER','root');
    define('SER_PASS','root');
    define('DB_NAME','wallpost');
    $connect=mysql_connect(SER_NAME,SER_USER,SER_PASS);
    if (
    $connect){
    // echo "Is Connect DB Ok"."</br>";
    $db mysql_select_db(DB_NAME);
    if (
    $db){
    // echo "DB is Ok ! <br />";
    }
    $sql ="SELECT * FROM postwall ";
    $querygetdata=mysql_query($sql);
    if (
    $querygetdata){
    // echo "query data is ok "."</br>";
    }
    while (
    $row mysql_fetch_assoc($querygetdata))
    {
    $id $row['id'];
    $name $row['name'];
    $email $row['email'];
    $msg $row['message'];
    $time $row['time'];
    $date $row['date'];
    // echo "$id - $name - $email - ";
    // show data to user into table
    echo "
    <table border=2 >
    <tr>
    <td>
    <b> Posted By $name [$email] on [$date] at [$time]</b>
    </td>
    </tr>
    <tr>
    <td>
    $msg
    </td>
    </tr>
    </tr>
    </table>


    "
    ;

    }
    };
    echo 
    "<hr>";
    $submit $_POST['sumbit'];
    if (
    $submit){

    $name $_POST['name'];
    if (!
    $name){
    echo 
    "Please Type Your Name.</br>";
    }elseif(
    is_numeric($name)){
    echo 
    "Please Do Not Fill Name With Numeric";
    }
    $email=$_POST['email'];
    $msg=$_POST['message'];
    $timedate("Y-m-d");
    $datedate("H:i:s");
    if (
    $name and $email and $msg )
    $sql "INSERT INTO wallpost VALUES(
    '$name','$msg','$date','$time','$email')"
    ;
    $querypost mysql_query($sql);
    if (
    $querypost){
    echo 
    "Thanks For Post";
    }}


    $firstpage =$_SERVER['PHP_SELF'];
    //HTML CODE(FORM)
    echo "
    <form action='$firstpage' method='POST'>
    <table border=0 width=100%>
    <tr>
    <td width='14%'>Your Name:</td>
    <td>
    <input type='text' name='name' maxlength='40'>
    </td>
    </tr>
    <tr>
    <td width='14%'>Your Email:</td>
    <td>
    <input type='text' name='email' maxlength='40'>
    </td>
    </tr>
    <tr>
    <td width='14%' valign='top'>Message:</td>
    <td>
    <textarea clos='30' rows='4' name='msg'
    maxlength='500'></textarea>
    </tr>
    </td>
    <tr>
    <td></td>
    <td>
    <input type='submit' name='sumbit' value'Post'>
    <input type='reset' name='reset' value'Clear'>
    </td>
    </tr>
    </form>
    </table>
    "
    ;
    ?>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    But what is your question???

    And did you notice this:
    Code:
    $submit = $_POST['sumbit'];
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    im writing in form .. msg and name and
    Does not appear even opened the page again

  • #4
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ^^help

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    There are so many mistakes in that I don't know where to begin. I found it easier to just rewrite your code.

    I do NOT know if this will work. But it has a better chance of working than your code did.

    Your database design is POOR!!! You should *NOT* have two separate fields for date and time. You should *NOT* try to pass the date and time in from PHP. Let MySQL supply them for you. Your <form> validation is a JOKE! It would be very very very easy for someone to completely mess up your site with a bit of SQL injection. Truly, all this code needs a lot of work. But even so it is better than what you had.

    Please notice the code highlighted in red, below. It is important.

    Code:
    <?php
    $connect = mysql_connect(SER_NAME,SER_USER,SER_PASS) or die( mysql_error() );
    
    $db = mysql_select_db(DB_NAME) or die( mysql_error() );
    
    // add a new record if requested...
    $submit = $_POST['submit']; 
    if ($submit)
    { 
        $name = $_POST['name']; 
        if ( $name == "" )
        { 
            echo "Please Type Your Name.</br>"; 
        } elseif(is_numeric($name)) { 
            echo "Please Do Not Fill Name With Numeric"; 
        } 
        $email=$_POST['email']; 
        $msg=$_POST['message']; 
        if ($name != "" && $email != "" && $msg != "" ) 
        {
            $sql = "INSERT INTO wallpost VALUES( 
                '$name','$msg',CURDATE(),CURTIME(),'$email')"; 
            if ( mysql_query($sql) )
            {
                echo "Thanks For Post"; 
            }
        }
    }
    
    
    $sql ="SELECT * FROM postwall "; 
    $querygetdata = mysql_query($sql) or die( mysql_error() );
    
    echo "        <table border=2 >\n";
    while ($row = mysql_fetch_assoc($querygetdata)) 
    { 
        $id = $row['id']; 
        $name  = $row['name']; 
        $email = $row['email']; 
        $msg   = $row['message']; 
        $time  = $row['time']; 
        $date  = $row['date']; 
        echo "        <tr> 
                <td> 
                    <b> Posted By $name [$email] on [$date] at [$time]</b> 
                </td> 
            </tr> 
            <tr> 
                <td> 
                    $msg 
                </td> 
            </tr> 
    "; 
    
    } 
    echo "</table><hr/>"; 
    
    $firstpage  = $_SERVER['PHP_SELF']; 
    //HTML CODE(FORM) 
    ?>
    <form action="<?php echo $firstpage; ?>" method='POST'> 
    <table border=0 width=100%> 
    <tr> 
        <td width='14%'>Your Name:</td> 
        <td><input type='text' name='name' maxlength='40'></td> 
    </tr> 
    <tr> 
        <td width='14%'>Your Email:</td> 
        <td><input type='text' name='email' maxlength='40'></td> 
    </tr> 
    <tr> 
        <td width='14%' valign='top'>Message:</td> 
        <td><textarea clos='30' rows='4' name='msg' maxlength='500'></textarea> 
    </tr> 
    <tr> 
        <td></td> 
        <td><input type='submit' name='submit' value'Post'>
            <input type='reset' name='reset' value-'Clear'></td> 
    </tr> 
    </table> 
    </form>
    As you can see, one place you used the table name postwall and the other place you used wallpost. I have no idea which one is correct.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Oh, yes...if it is not obvious: *OF COURSE* you should INSERT the *NEW* data *BEFORE* trying to display all posts! It makes no sense to do the INSERT *after* the SELECT!!!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    fix it for me

  • #8
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Quote Originally Posted by MostafaSaadi View Post
    fix it for me
    I did. Or I tried. Did you even *READ* my post #5???
    If you aren't willing to try my code, then I don't know how I can help you.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is not work

  • #11
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    Quote Originally Posted by MostafaSaadi View Post
    is not work
    Which tells me *NOTHING*. HOW does it not work? What DEBUG work have you done?

    I cannot help you if you do not help yourself!
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #12
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    NO debug

    but she dont post anything in page

    Do not print anything that is not a message like Facebook
    +
    my work this is done

  • #13
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    NO debug

    but she dont post anything in page

    Do not print anything that is not a message like Facebook
    +
    my work this is done

    ^^^

  • #14
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,613
    Thanks
    80
    Thanked 4,635 Times in 4,597 Posts
    "my work this is done" also.

    I don't know anything else to do. You still refuse to tell us *WHAT* is wrong.

    If you don't learn how to DEBUG your code, we usually can't help you.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #15
    New Coder
    Join Date
    Oct 2014
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok good bay for you

    --

    WTF Fourm anyone help me plzz


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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