We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,134 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

inserting data into mysql from radio button form in PHP

I am trying to insert my form's data radio buttons into my mysql database. it works very well but when i skip any one value of my radio button,as this is more than 20, its giving error that

Notice: Undefined index: qr1 in C:\wamp\www\exam\contents\omr.php on line 134
Call Stack
#   Time    Memory  Function    Location
1   0.0018  148808  {main}( )   ..\omr.php:0

but in the database, i am getting my desired result, means all the values are got inserted and which radio button is not put in the form, inseting with blank, as i want.. and also executing lines which is written after mysql query in the program.
so how can i debug my error??
hope you got my problem..plss anyone help me.

3
Contributors
5
Replies
1 Day
Discussion Span
6 Months Ago
Last Updated
7
Views
manishp5
Newbie Poster
4 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

you will need to post all of your code. But it sounds like the problem is after your code to insert into the database. Id start there.

leviathan185
Junior Poster
157 posts since May 2009
Reputation Points: 24
Solved Threads: 19
Skill Endorsements: 0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>rightframe</title>
</head>
<body bgcolor="green">
<?php 
    // Connects to your Database 
    require_once("connection.php");

    //checks cookies to make sure they are logged in 
    if(isset($_COOKIE['ID_my_site'])) 
    { 
        $username = $_COOKIE['ID_my_site']; 
        $pass = $_COOKIE['Key_my_site']; 
        $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
        while($info = mysql_fetch_array( $check ))   
        { 
             //if the cookie has the wrong password, they are taken to the login page 
            if ($pass != $info['password']) 
            {           
                header("Location: login.php"); 
            } 
             else 
            { 

?>

<form name="input" action="" method="post">
User Name: <input type="text" name="roll" value="" /><br />
Reasoning
<br />
QR01.
<input type="radio" name="qr1" value="a">
<input type="radio" name="qr1" value="b">
<input type="radio" name="qr1" value="c">
<input type="radio" name="qr1" value="d">
<input type="radio" name="qr1" value="e">
<br />
QR02.
<input type="radio" name="qr2" value="a">
<input type="radio" name="qr2" value="b">
<input type="radio" name="qr2" value="c">
<input type="radio" name="qr2" value="d">
<input type="radio" name="qr2" value="e">
<br />
QR03.
<input type="radio" name="qr3" value="a">
<input type="radio" name="qr3" value="b">
<input type="radio" name="qr3" value="c">
<input type="radio" name="qr3" value="d">
<input type="radio" name="qr3" value="e">
<br />
QR04.
<input type="radio" name="qr4" value="a">
<input type="radio" name="qr4" value="b">
<input type="radio" name="qr4" value="c">
<input type="radio" name="qr4" value="d">
<input type="radio" name="qr4" value="e">
<br />
QR05.
<input type="radio" name="qr5" value="a">
<input type="radio" name="qr5" value="b">
<input type="radio" name="qr5" value="c">
<input type="radio" name="qr5" value="d">
<input type="radio" name="qr5" value="e">
<br />

<!--
    till qr50......
-->

<input type="submit" name="submit" value="Submit">
</form> 

<?php
                 if (isset($_POST['submit']))
                 {
                    $insert = "INSERT INTO omr (roll, qr1, qr2, qr3, qr4, qr5)
                               VALUES('".$_POST['roll']."', '".$_POST['qr1']."', '".$_POST['qr2']."', '".$_POST['qr3']."',
                               '".$_POST['qr4']."', '".$_POST['qr5']."')";
                    mysql_query($insert);
                    echo "Your answers is submitted now";       
                 } 
            } 
        } 
     } 
     else 
     //if the cookie does not exist, they are taken to the login screen 
     {           
        header("Location: login.php"); 
     } 
?> 
</body>
</html>
manishp5
Newbie Poster
4 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

this is all my code..now plss help me..

manishp5
Newbie Poster
4 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

ill see if i can help.

fobos
Posting Whiz
345 posts since Feb 2009
Reputation Points: 29
Solved Threads: 67
Skill Endorsements: 3

hey guys please help me..my project work is goining in pending just because of thi s error...

manishp5
Newbie Poster
4 posts since Oct 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.3359 seconds using 2.71MB