Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    1

    Unanswered: .........dating website...........

    Hey can anybody tell me whats wrong with this code. Whenever i press the submit button it does not seem to execute anything. I am using foxserve as my localhost and i am logged into MYSQLadmin as sleekfx. Can anybody shed some much needed light on the matter.


    Thanks.


    <HTML>
    <HEAD>
    <TITLE>Putting data</TITLE>
    </HEAD>
    <BODY>
    <?php
    /* This program enters news items into a database */

    if(isset($submit)) {

    $db = mysql_connect ("localhost", "sleekfx");

    mysql_select_db ("DBNAME", $db);

    $date = date("Y-m-d");

    $sql = "INSERT INTO news

    VALUES (NULL, '$heading','$body', '$date',
    '$auth', '$auth_email')";

    mysql_query($sql);

    print("<h2>The data has been entered.</h2>");
    print("<b>You can add another news story below</b>");

    }
    ?>

    <h1>Enter your news item into the database</h1>
    <form action="data_in.php" method="post"><br>
    Name:<br> <input type ="text" name="auth"> <br>
    Email:<br> <input type ="text" name="auth_email"><br>
    Heading:<br> <input type ="text" name="auth"> <br>
    News:<br> <input type ="text" name="body"> <br>

    <input type="submit" name="submit" value="Submit News!">
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Feb 2004
    Location
    Ninth Hell
    Posts
    19
    You should check if register_globals is turned on in your php configuration. A replacement for your php code if you are running a newer php version is:

    Code:
    <?php 
    /* This program enters news items into a database */ 
    
    if(isset($_POST['submit'])) { 
    
    $db = mysql_connect ("localhost", "sleekfx"); 
    
    mysql_select_db ("DBNAME", $db); 
    
    $date = date("Y-m-d"); 
    
    $sql = "INSERT INTO news 
    VALUES (NULL, '".$_POST['heading']."','".$_POST['$body']."', '".$_POST['date']."', 
    '".$_POST['auth']."', '".$_POST['auth_email']."')"; 
    
    mysql_query($sql); 
    
    print("<h2>The data has been entered.</h2>"); 
    print("<b>You can add another news story below</b>"); 
    
    } 
    ?>
    Also
    where you have:
    Code:
    Heading:<br> <input type ="text" name="auth"> <br>
    it should be:
    Code:
    Heading:<br> <input type ="text" name="heading"> <br>

Posting Permissions

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