Form not submitting correctly

Discussion in 'PHP' started by El Duderino, Nov 19, 2007.

  1. #1
    I'm stuck!

    I have a page that should be adding a listing in my database. When the form submits, the page refreshes with blank fields and nothing happens. Nothing is added to the database.

    Any idea what I might be doing wrong here?


     
    El Duderino, Nov 19, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    What output/error do you get with this?
    
    <?php
    
    error_reporting(E_ALL);
    
    include ("include/header.inc.php");
    ?>
    
    <h1>Add a Listing</h1>
    <?php
    include("include/dbconnect.php");
    
    if(isset($_POST['submit']))
    {
    	$item = mysql_real_escape_string($_POST['item']);
    	$detail = mysql_real_escape_string($_POST['detail']);
    	
    	$sql = "INSERT INTO $table (item, detail) VALUES ('$item','$detail')";
    	$result = mysql_query($sql) OR die(mysql_error());
    	echo "<br><br>Item has been added.\n";
    }
    
    else
    {
    ?>
    <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] ;?>">
    
    <table width="380" border="0" cellspacing="1" cellpadding="1">
    <tr>
    <td>
    <input type="hidden" name="id" value="<?php echo $myrow["id"]?>">
    Item:</td>
    <td>
    <input type="Text" name="item" size="35">
    </td>
    </tr>
    <tr>
    <td>Detail: </td>
    <td>
    <input type="Text" name="detail" size="35">
    </td>
    </tr>
    
    
    </table>
    <input type="Submit" name="submit" value="Enter information">
    </form>
    <?php
    }
    include ("include/footer.inc.php");
    ?>
    
    PHP:
     
    nico_swd, Nov 19, 2007 IP
  3. El Duderino

    El Duderino Peon

    Messages:
    102
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    that did the trick! thanks!
     
    El Duderino, Nov 19, 2007 IP