Welcome! Log In Create A New Profile

Advanced

notice: undefined index

Posted by collins 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
notice: undefined index
May 19, 2013 03:30PM
Hi All,

Am having an error notice on my script could someone help, have been battling and I can't seem to pick up.
Language: PHP
<?php include("./include/config.php");   /*if (isset($_POST[';submit';])) {*/ $coursesql = "SELECT * FROM course"; $result = mysql_query($coursesql) or die("Invalid query: " . mysql_error()); while ($row = mysql_fetch_array($result)) { $course[$row[';cid';]] = $row[';cname';]; } switch ($_GET[';action';]) { case "edit": $studentsql = "SELECT * FROM student WHERE sno = ';" . $_GET[';sno';] ."';"; $result = mysql_query($studentsql) or die("Invalid Query:" . mysql_error()); $row = mysql_fetch_array($result); $sname = $row[';sname';]; $init = $row[';init';]; $fname = $row[';fname';]; $title = $row[';title';]; $msname = $row[';msname';]; $dob = $row[';dob';]; $gen = $row[';gen';]; $lang = $row[';lang';]; $idno = $row[';idno';]; $telh = $row[';telh';]; $telw = $row[';telw';]; $cel = $row[';cel';]; $fax = $row[';fax';]; $email = $row[';email';]; $address = $row[';address';]; $contact_flag = $row[';contact_flag';]; break;   default: $sname = ""; $init = ""; $fname = ""; $title = ""; $msname = ""; $dob = ""; $gen = ""; $lang = ""; $idno = ""; $telh = ""; $telw = ""; $cel = ""; $fax = ""; $email = ""; $address = ""; $contact_flag = ""; break; } /*}*/ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Student Registration Form</title> <?php include("./include/menu.php"); ?>   <h1>Register for a course</h1> <form action="process_student.php?action=<?php echo $_GET[';action';];?>&type=student&sno=<?php /*if (isset ($_GET[';sno';])) */{echo $_GET[';sno';]; }?>" method="post"> <table width="700" border="0"> <tr> <td width="390"></td> <td width="287"></td> </tr> <tr> <td><label for="cname">Course Name</label></td> <td><select name="cname" id="cname"> <option value=" " selected="selected">Select a course...</option> <?php $query = "SELECT cname, cid FROM course ORDER BY cid"; $result = mysql_query($query) or die(mysql_error());   while ($row = mysql_fetch_assoc($result)) { echo ';<option value="'; . $row[';cid';] . ';">'; . $row[';cname';] . ';</option>'; . "\r\n"; } ?> </select> </td> </tr> <tr> <td><label for="sname">Surname</label></td> <td> <input type="text" name="sname" id="sname" value="<?php echo $sname; ?>" /></td> </tr> <tr> <td><label for="init">Initials</label></td> <td> <input type="text" name="init" id="init" value="<?php echo $init; ?>" /></td> </tr> <tr> <td><label for="fname">Full First Name</label></td> <td> <input type="text" name="fname" id="fname" value="<?php echo $fname; ?>"/></td> </tr> <tr> <td><label for="title">Title</label></td> <td> <select name="title" id="title"> <option selected="selected" value="">Select Your Title...</option> <option value="mr">Mr.</option> <option value="miss">Miss</option> <option value="mrs">Mrs</option> <option value="ms">Ms</option> <option value="doctor">Dr.</option> <option value="professor">Professor</option> </select></td> </tr> <tr> <td><label for="msname">Maiden or Previous Surname</label></td> <td> <input type="text" name="msname" id="msname" value="<?php echo $msname; ?>"/></td> </tr> <tr> <td><label for="dob">Date of Birth(yyyy-mm-dd)</label></td> <td><input type="text" name="dob" id="dob" value="<?php echo $dob; ?>" /></td> </tr> <tr> <td><label for="gen">Gender</label></td> <td> <select name="gen" id="gen"> <option value="" selected="selected">Please select your gender...</option> <option value="male">Male</option> <option value="female">Female</option> </select></td> </tr> <tr> <td><label for="lang">Language for correspondence</label></td> <td> <select name="lang" id="lang"> <option value="" selected="selected">Please select your language</option> <option value="afrikaans">Afrikaans</option> <option value="english">English</option> <option value="french">French</option> <option value="ndebele">Ndebele</option> <option value="portuguese">Portuguese</option> <option value="sotho">Sotho</option> <option value="xhosa">Xhosa</option> <option value="zulu">Zulu</option> </select></td> </tr> <tr> <td><label for="idno">Identity Number</label></td> <td> <input type="text" name="idno" id="idno" value="<?php echo $idno; ?>" /></td> </tr> <tr> <td><label for="telh">Home Telephone Code + Number</label></td> <td> <input type="text" name="telh" id="telh" value="<?php echo $telh; ?>" /></td> </tr> <tr> <td><label for="telw">Work Telephone Code + Number</label></td> <td> <input type="text" name="telw" id="telw" value="<?php echo $telw; ?>"/></td> </tr> <tr> <td><label for="cel">Cell Phone Number</label></td> <td> <input type="text" name="cel" id="cel" value="<?php echo $cel; ?>"/></td> </tr> <tr> <td><label for="fax">Fax Code + Number</label></td> <td> <input type="text" name="fax" id="fax" value="<?php echo $fax; ?>" /></td> </tr> <tr> <td><label for="email">E-Mail Address</label></td> <td> <input type="text" name="email" id="email" value="<?php echo $email; ?>" /></td> </tr> <tr> <td><label for="address">Postal Address</label></td> <td> <textarea name="address" id="address" cols="45" rows="5"></textarea></td> </tr> <tr> <td><label for="contact_flag">Allow Sharing of Contact Details</label></td> <td><input type="checkbox" name="contact_flag" id="contact_flag" value="<?php echo $contact_flag; ?>" /> </td> </tr> <tr> <td align="right"><input type="submit" name="SUBMIT" value="<?php echo $_GET[';action';]; ?>"></td> <td><input type="submit" name="reset" value="reset" /></td> </tr> </table>     </form>   <?php include("./include/footer.php"); ?>
Re: notice: undefined index
May 20, 2013 07:49AM
What's the error message saying?

78026962 afojonny
Re: notice: undefined index
May 20, 2013 08:03AM
It will be easier if you post an error msg, that way we will know where to look. you code it way too long, 1. we have to figure out what you trying to do, and also figure out what you are doing wrong... that's too much.

rather send an error msg you are getting, it will probable point us to a line with an error and give u a clue of what it could be.
Re: notice: undefined index
May 20, 2013 09:49AM
Notice: Undefined index: action in C:\xampp\htdocs\portfolio\student_reg.php on line 10
Re: notice: undefined index
May 20, 2013 09:51AM
and this is the script that processes this page:

Language: PHP
<?php //Commit Add and Edits include"./include/menu.php"; include "./include/config.php"; switch($_GET[';action';]) { case "edit": switch ($_GET[';type';]) { case "student": $sql = "UPDATE student SET sname = ';" . $_POST[';sname';] . "';, init = ';" . $_POST[';init';] . "';, fname = ';" . $_POST[';fname';] . "';, title = ';" . $_POST[';title';] . "';, msname = ';" . $_POST[';msname';] . "';, dob = ';" . $_POST[';dob';] . "';, gen = ';" . $_POST[';gen';] . "';, lang = ';" . $_POST[';lang';] . "';, idno = ';" . $_POST[';idno';] . "';, telh = ';" . $_POST[';telh';] . "';, telw = ';" . $_POST[';telw';] . "';, cel = ';" . $_POST[';cel';] . "';, fax = ';" . $_POST[';fax';] . "';, email = ';" . $_POST[';email';] . "';, address = ';" . $_POST[';address';] . "';, contact_flag = ';" . $_POST[';contact_flag';] . "'; WHERE sno = ';" . $_GET[';sno';] . "';" ; break; } break; case "add": switch ($_GET[';type';]) { case "student": $sql = "INSERT INTO student (sname, init, fname, title, msname, dob, gen, lang, idno, telh, telw, cel, fax, email, address, contact_flag) VALUES (';" . $_POST[';sname';] . "';, ';" . $_POST[';init';] . "';, ';" . $_POST[';fname';] . "';, ';" . $_POST[';title';] . "';, ';" . $_POST[';msname';] . "';, ';" . $_POST[';dob';] . "';, ';" . $_POST[';gen';] . "';, ';" . $_POST[';lang';] . "';, ';" . $_POST[';idno';] . "';, ';" . $_POST[';telh';] . "';, ';" . $_POST[';telw';] . "';, ';" . $_POST[';cel';] . "';, ';" . $_POST[';fax';] . "';, ';" . $_POST[';email';] . "';, ';" . $_POST[';address';] . "';, ';" . $_POST[';contact_flag';] . "';)"; break; } break; } if (isset($sql) && !empty($sql)) { echo "<!--" . $sql . "-->"; $result = mysql_query($sql) or die("Invalid query: " .mysql_error()); ?> <?php if (isset($sql) && !empty($sql)) { $subject = $subject;   $message = "Name: $name \n Telephone: $telephone \n Cell: $cell \n Email: $email \n Subject: $subject \n Enquiry: $themessage \n";   $from = "From: $email\r\n";   mail($_GET[';email';] , $subject, $message, $from); } ?> <p align="center" style="color: #ff0000"> Done. <a href="index.php">Index</a> </p> <?php } include"./include/footer.php"; ?>
Re: notice: undefined index
May 20, 2013 10:14AM
please copy and paste only line 10. I cant tell which Is line 10 because this could be part of the code in your page.
Re: notice: undefined index
May 20, 2013 10:27AM
This is line 10
Language: PHP
switch ($_GET[';action';]) {

And it doesn't make sense to me because the action is already declared.
avatar Re: notice: undefined index
May 20, 2013 10:45AM
Check the lines before line 10. It could be that it is saying the error is on line 10, but further up you have forgotten a ; or { . It also means that a certain variable is not declared yet.
Re: notice: undefined index
May 20, 2013 11:19AM
I checked over and over and I don't seem to have missed a ;
avatar
Mac
Re: notice: undefined index
May 20, 2013 03:48PM
collins Wrote:
-------------------------------------------------------
> Notice: Undefined index: action in
> C:\xampp\htdocs\portfolio\student_reg.php on line
> 10


This has been answered somewhere else. Just do a search on this forum for "undefined index"
Sorry, only registered users may post in this forum.

Click here to login