Jump to content

Undefined index


Go to solution Solved by 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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