Jump to content

Undefined index


cornelombaard

Recommended Posts

Hi I am new to this

 

When you have a form with various fields in them and you have given names to each field. If you submit that form then the values go sit in the array $_REQUEST am I correct? Then why do I get a index undefined?

 

Here is the code for the form:

<code>

<h2>
    Sign my guestbook
</h2>
<form method="post" action="entry.php">
    <b>Name:</b>
    <input type="text" size="40" name="name">
    <br><br>
    <b>Location:</b>
    <input type="text" size="40" name="location">
        <br><br>
    <b>Email:</b>
    <input type="text" size="40" name="email">
        <br><br>
    <b>Homepage:</b>
    <input type="text" size="40" name="url">
        <br><br>
    <b>Comments:</b>
    <textarea name=”comments” cols=”40” rows=”4”
    wrap=”virtualv></textarea>

    <br><br>
<input type="submit" name="submit" value="Sign!"> <input type="reset" name="reset" value="Start over">

    </form>
</form>

</code>

 

Here is the code for entry.php

 

<code>

<?php

include 'includes/dbconnect.php';
if($_REQUEST['submit'] == "Sign!")
{
    $query = "insert into guestbook (name, location, email, url, comments) values ('".$_REQUEST['name']."',
        '".$_REQUEST['location']."', '".$_REQUEST['email']."', '".$_REQUEST['url']."', '".$_REQUEST['comments']."')";
    mysql_query($query);

?>
<h2>Thanks</h2>
<h3><a href="view.php">View my guesbook</a></h2>
<?php
}
else
{
    include 'sign.php';
}
?>

</code>

 

I need to understand what happend when a form is submitted where fields have names and the method used it post.

 

Any help is greatly appreciated Thanks

Link to comment
https://forums.phpfreaks.com/topic/283226-undefined-index/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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