PHP - Notice: Undefined Index
I have a form and a validation both on the same page, however I'm getting notices since I have undefined variables. How do I get around this?
Notice: Undefined index: submit in C:\xampp\htdocs\5dollar\register.php on line 10 Notice: Undefined index: password in C:\xampp\htdocs\5dollar\register.php on line 12 Notice: Undefined index: repeatpassword in C:\xampp\htdocs\5dollar\register.php on line 13 Notice: Undefined index: paypalemail in C:\xampp\htdocs\5dollar\register.php on line 14 $submit = $_POST['submit']; $password = strip_tags($_POST['password']); $repeatpassword = strip_tags($_POST['repeatpassword']); $paypalemail = strip_tags($_POST['paypalemail']); Similar Tutorialshi, I need help really badly for my PHP-Postcard Script. Basically it sends the card out but the URL does not work, I get the following error message: The URL is not valid and cannot be loaded It also states that Notice: Undefined index: www.voluntary.awardspace.co.uk in /home/www/voluntary.awardspace.co.uk/Postcard.php on line 25 Notice: Undefined index: Postcard.php in /home/www/voluntary.awardspace.co.uk/Postcard.php on line 25 See Code below: <?php session_start(); //check error log ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); // CHANGE PARAMETERS HERE BEGIN $senderName = " Holidays From Home "; // Eg.: John's Postcards $senderEmail = "chris01@voluntary.awardspace.co.uk"; // Eg.: john@postcard.com // Change only if you have problems with urls $postcardURL = "http://".$_SERVER["www.voluntary.awardspace.co.uk"].$_SERVER["Postcard.php"]; // CHANGE PARAMETERS HERE END $result = 0; $msg = ""; $msg1 = ""; $pic = ""; function displayPhotos() { global $pic; $columns = 5; $act = 0; $act1 = 0; // Open the actual directory if($handle = opendir("thumbs")) { // Read all file from the actual directory while($file = readdir($handle)) { if(!is_dir($file)) { if(isset($pic[1])) { if($pic[1] == $act1){$sel = "checked";} else{$sel = "unchecked";} } if($act == 0){echo "<tr>";} echo "<td align='center'><img src='thumbs/$file' alt='postcard'/><br/><input type='radio' name='selimg' value='$file,$act1' $sel/></td>"; $act++; $act1++; if($act == $columns){$act = 0;echo "</tr>";} } } echo "</tr>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Micro Postcard</title> <link href= "style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="style1" id="caption"> <div align="left" class="style1"></div> </div> <?php //makes sure form is correctly filled in if(!empty($_POST["submit"])) { if(empty($_POST["selimg"])){$msg = "Please select an image from above!";$result = 3;} else{$pic = explode(",",$_POST["selimg"]);} if(empty($_POST["email"]) && empty($result)){$msg1 = "You must enter an email address!";$result = 3;} $secCode = empty($_POST["secCode"]) ? "" : strtolower($_POST["secCode"]); if($secCode == $_SESSION["securityCode"] && $result != 3) { $filename = date("YmdGis"); $f = fopen("messages/".$filename.".txt","w+"); fwrite($f,$pic[0]."\n"); fwrite($f,$_POST['email']."\n"); fwrite($f,stripslashes($_POST["message"])."\n"); fclose($f); // Compose the mail $from = "From: $senderName <$senderEmail>\r\n"; $replay = "Reply-To: $senderEmail\r\n"; $params = "MIME-Version: 1.0\r\n"; $params .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $mailtext = "You have just received a Virtual Postcard!\r\n\r\n You can pick up your postcard at the following web address:\r\n $postcardURL?show=$filename\r\n\r\n We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself!\r\n\r\n Regards,\r\n Holidays From Home\r\n $postcardURL"; // Send email @mail($_POST["email"],"You've received a postcard",$mailtext,$from.$replay.$params); echo "<center> Your postcard was sent successfully!<br /><br /> <img src='images/$pic[0]' alt='postcard' /><br /><br /><br />".stripslashes($_POST["message"]). "</center>"; $result = 1; } else{if($result != 3){$result = 2;}} } if(!empty($_GET["show"])) { $file = $_GET["show"]; $content = file("messages/$file.txt"); $pic = $content[0]; unset($content[0]); unset($content[1]); foreach($content as $value){$main .= $value;} echo "<center> Your postcard!<br /><br /> <img src='images/$pic' alt='postcard' /><br /><br /><br />$main </center>"; } if((empty($result) || $result == 2 || $result == 3) && empty($_GET["show"])) { echo "<form action='#' method='post'> <table align='center'>"; displayPhotos(); echo "</table> <div style='color:#f00;font-size:16px;'>$msg</div> <h2>Fill in the Form and then click on Send Card!!</h2> <table width='100%'> <tr><td>Send to (email address):</td><td><div style='color:#f00;font-size:16px;'>$msg1</div><input type='text' name='email' size='30' value='".$_POST["email"]."' /></td></tr> <tr><td>Message:</td><td><textarea name='message' rows='10' cols='40'>".stripslashes($_POST["message"])."</textarea></td></tr> <tr><td colspan='2'>".($result == 2 ? "<p style='color:#f00;font-size:16px;'>Sorry the security code is invalid! Please try it again!</span></p>" : " ")."</tr> <tr> <td>Security code: <input class='text' name='secCode' type='text' size='10' /> </td><td><img src='securityCode.php' alt='security code' border='1' /></td> </tr> <tr><td colspan='2'> </tr> <tr><td colspan='2' align='left'><input type='submit' value='Send card!' name='submit'/></td></tr> </table> </form>"; } ?> Absolutely any help would be much appreciated. I want ot know is there a way round this problem? Here is the http://voluntary.awardspace.co.uk/Postcard.php I am absolutely desperate to solve this burning issue Notice: Undefined index: category in C:\xampp\htdocs\content\cron\check_deposits.php on line 18
Notice: Undefined index: confirmations in C:\xampp\htdocs\content\cron\check_deposits.php on line 19
Notice: Undefined index: address in C:\xampp\htdocs\content\cron\check_deposits.php on line 20
Notice: Undefined index: amount in C:\xampp\htdocs\content\cron\check_deposits.php on line 21
Notice: Undefined index: txid in C:\xampp\htdocs\content\cron\check_deposits.php on line 22
<?php // CRON must be running every minute! $included=true; include '../../inc/db-conf.php'; include '../../inc/wallet_driver.php'; $wallet=new jsonRPCClient($driver_login); include '../../inc/functions.php'; $deposits=mysql_query("SELECT * FROM `deposits`"); while ($dp=mysql_fetch_array($deposits)) { $received=0; $txid=''; $txs=$wallet->listtransactions('',2000); $txs=array_reverse($txs); foreach ($txs as $tx) { if ($tx['category']!='receive') continue; if ($tx['confirmations']<1) continue; if ($tx['address']!=$dp['address']) continue; $received=$tx['amount']; $txid=$tx['txid']; break; } if ($received<0.00000001) continue; $txid=($txid=='')?'[unknown]':$txid; if ($dp['received']==1) { mysql_query("UPDATE `deposits` SET `confirmations`=`confirmations`+1 WHERE `id`=$dp[id] LIMIT 1"); if (++$dp['confirmations']>=6) { $delExed=false; do { $delExed=mysql_query("DELETE FROM `deposits` WHERE `id`=$dp[id] LIMIT 1"); } while ($delExed==false); mysql_query("UPDATE `players` SET `balance`=TRUNCATE(ROUND((`balance`+$received),9),8) WHERE `id`=$dp[player_id] LIMIT 1"); mysql_query("INSERT INTO `transactions` (`player_id`,`amount`,`txid`) VALUES ($dp[player_id],$dp[amount],'$dp[txid]')"); } continue; } mysql_query("UPDATE `deposits` SET `received`=1,`amount`=$received,`txid`='$txid' WHERE `id`=$dp[id] LIMIT 1"); } mysql_query("DELETE FROM `deposits` WHERE `time_generated`<NOW()-INTERVAL 7 DAY"); ?>For some reason I am getting all these errors, and I cannot figure out why? Is there anyone out there that thinks they know what is wrong with it? I got this error when i click update button Notice: Undefined index: name in C:\wamp\www\mariyano\New Folder - Copy\New\update.php on line 14 Notice: Undefined index: mobile in C:\wamp\www\mariyano\New Folder - Copy\New\update.php on line 14 Notice: Undefined index: email in C:\wamp\www\mariyano\New Folder - Copy\New\update.php on line 14 Unknown column 'diwakar' in 'where clause' Code: [Select] <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("super",$cn); if(isset($_POST['submit'])) { //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $qy="UPDATE users SET name='$_POST[name]', email='$_POST[mobile]', city='$_POST[email]' WHERE username=$username "; mysql_query($qy,$cn) or die(mysql_error()); } } ?> Code: [Select] <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("super",$cn); //checks cookies to make sure they are logged in if(!isset($_COOKIE['ID_my_site'])) { header("Location: login.php"); } echo "<h3>Profiles</h3><br/><br/>"; echo "Name: <input type=\"text\" name=\"name\" > "; echo "<br/>"; echo "Email: <input type=\"text\" name=\"email\"> "; echo "<br/>"; echo "City: <input type=\"text\" name=\"city\"> "; //echo "<br/><br/><input type=\"submit\" value=\"Update\" >"; //echo "<br/><br/><a href=logout.php>Logout</a>"; ?> <html> <form action='update.php' method='post'> <br/> <input type='submit' name='submit' value='Update' > <br/><br/><a href=logout.php>Logout</a> </form> </html> hi, can anyone tell me anything wrong with my coding as it keeps mentioned undefined index,id
Attached Files
tambahitem.php 5.08KB
1 downloads I realize others have had problems with the undefined index issue, but I can't find any answer to my particular problem in any forum, anywhere. I have a form/script which uploads images with description for an artist site. There are 25 images available to upload (an artist profile image and 24 art images), and the images 1-19 upload just fine. All the images share exactly the same code. But when the processing script comes to image 20, it fails and I get the "undefined index" notice. Here is the processing code for image 19-20. Code: [Select] //There are a total of 20 other blocks of code above this one, //and they are all the same except for the image number. //Artimage19 Process Begin $artimage19 = $_FILES['artimage19']['name']; $file_size = $_FILES['artimage19']['size']; $file_temp = $_FILES['artimage19']['tmp_name']; $title19 = $_POST['title19']; $disptitle19 = stripslashes($title19); $medium19 = $_POST['medium19']; $dim19 = $_POST['dim19']; $price19 = $_POST['price19']; $file_basename = substr($artimage19, 0, strripos($artimage19, '.')); // strip extention $file_ext = substr($artimage19, strripos($artimage19, '.')); $allowed_extensions['ext']= array('jpeg','jpg','gif','png'); if(!$allowed_extensions){ echo "Artimage19 file extension not allowed."; }else{ $file_ext = strtolower($file_ext); $random = rand(0000, 9999); $new_file_name19 = $surname.$random. '.' .$file_ext; } if($file_size > MAX_SIZE*1024) { echo 'ARTIMAGE19 FILE SIZE TO LARGE<BR />'; } if(move_uploaded_file($file_temp, "$filepath/$new_file_name19")) { //echo '<h3>Upload Successful!</h3>'; } else { echo '<h3>ERROR IN UPLOADING ARTIMAGE19</h3>'; } //Artimage19 Process Ends //Artimage20 Process Begin $artimage20 = $_FILES['artimage20']['name']; $file_size = $_FILES['artimage20']['size']; $file_temp = $_FILES['artimage20']['tmp_name']; $title20 = $_POST['title20']; $disptitle20 = stripslashes($title20); $medium20 = $_POST['medium20']; $dim20 = $_POST['dim20']; $price20 = $_POST['price20']; $file_basename = substr($artimage20, 0, strripos($artimage20, '.')); // strip extention $file_ext = substr($artimage20, strripos($artimage20, '.')); $allowed_extensions['ext']= array('jpeg','jpg','gif','png'); if(!$allowed_extensions){ echo "Artimage20 file extension not allowed."; }else{ $file_ext = strtolower($file_ext); $random = rand(0000, 9999); $new_file_name20 = $surname.$random. '.' .$file_ext; } if($file_size > MAX_SIZE*1024) { echo 'ARTIMAGE20 FILE SIZE TO LARGE<BR />'; } if(move_uploaded_file($file_temp, "$filepath/$new_file_name20")) { //echo '<h3>Upload Successful!</h3>'; } else { echo '<h3>ERROR IN UPLOADING ARTIMAGE20</h3>'; } //Artimage20 Process Ends Artimage19 uploads just fine, but Artimage20 fails. The $filepath is set correctly, as it uploads all previous image files. The code for the submitting code is fine also. Here is the code that submits the data. Code: [Select] //The form header is below <form action="pdregisterres.php" method="POST" enctype="multipart/form-data" onSubmit="return checkrequired(this)"> //there are 18 others above this plus one for an artist profile image <tr><td colspan = "2"><hr></td></tr> <tr><td align = "left">Art Image 19:</td><td align = "left"><input type = "file" name = "artimage19"></td></tr> <tr><td align = "left">Title:</td><td align = "left"><input type = "text" name = "title19"></td></tr> <tr><td align = "left">Medium:</td><td align = "left"><input type = "text" name = "medium19"></td></tr> <tr><td align = "left">Dimensions:</td><td align = "left"><input type = "text" name = "dim19"></td></tr> <tr><td align = "left">Price:</td><td align = "left"><input type = "text" name = "price19"></td></tr> <tr><td colspan = "2"><hr></td></tr> <tr><td align = "left">Art Image 20:</td><td align = "left"><input type = "file" name = "artimage20"></td></tr> <tr><td align = "left">Title:</td><td align = "left"><input type = "text" name = "title20"></td></tr> <tr><td align = "left">Medium:</td><td align = "left"><input type = "text" name = "medium20"></td></tr> <tr><td align = "left">Dimensions:</td><td align = "left"><input type = "text" name = "dim20"></td></tr> <tr><td align = "left">Price:</td><td align = "left"><input type = "text" name = "price20"></td></tr> For some reason that I can't get, the form stops processing after Artimage19 and gives me this: Notice: Undefined index: artimage20 in /home/www/artistsofeureka.info/members/pdregisterres.php on line 1046 I also get the error message: ERROR IN UPLOADING ARTIMAGE20 I get this for images 20-24. Since the code for all image processing is exactly the same (except for image #), I can't see why it stops at #19. These images are being uploaded to a folder on my server and a mysql db. Images up to #19 upload just fine. Any comments, questions or helpful advice? This code seems to work fine in older versions of PHP, but in newer.. I get an error message... Code: [Select] $tagArray = $temp = array(); $temp = explode(',', $words); foreach($temp as $tag){ $tagArray[trim($tag)]++; } The error message is: "Notice: Undefined index: 1..." I assume I can just turn off the error reporting, but I'd really rather fix the problem. Does anyone know what's going on? Thank you. I have an error on this page but dont know how to correct it, any suggestions? It's coming from <?php if(!validateImage($_POST['image'])):?> add_test.php Code: [Select] <?php include("validation.php"); ?> <!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>Test Area</title> <link rel="stylesheet" href="test.css" type="text/css" media="screen" /> </head> <body> <div id="container"> <h1>Add a Product</h1> <?php if(isset($_POST['send']) AND (!validateModel($_POST['model']) || !validatePrice($_POST['price']) || !validateProduct($_POST['product']) || !validateImage($_POST['image']) || !validateDescription($_POST['description']) ) ):?> <div id="error"> <ol> <?php if(!validateModel($_POST['model'])):?> <li><strong>Invalid Model:</strong> Model Number must be more than 3 letters!</li> <?php endif?> <?php if(!validatePrice($_POST['price'])):?> <li><strong>Invalid Price:</strong> Price must be in integers!</li> <?php endif?> <?php if(!validateProduct($_POST['product'])):?> <li><strong>Invalid Product:</strong> You didn't select a product!</li> <?php endif?> <?php if(!validateImage($_POST['image'])):?> <li><strong>Invalid Image:</strong> You didn't select an image! - (ONLY: GIF/JPEG/JPG/PNG)</li> <?php endif?> <?php if(!validateDescription($_POST['description'])):?> <li><strong>Invalid Description:</strong> Description must have at least 10 characters in length!</li> <?php endif?> </ol> </div> <?php elseif(isset($_POST['send'])):?> <div id="error" class="valid"> <ul> <li><strong>Congratulations!</strong> All fields are OK ;)</li> </ul> </div> <?endif?> <form method="post" id="customForm" action="" enctype="multipart/form-data"> <div> <label for="model">Model Number</label> <input id="model" name="model" type="text" /> <span id="modelInfo">Please enter your Product Model Number!</span> </div> <div> <label for="product">Product</label> <select class="product" name="product"> <option value="please_select">Please select an option below</option> <option value="1">19" LCD TV</option> <option value="2">22" LCD TV</option> <option value="3">26" LCD TV</option> <option value="4">32" LCD TV</option> <option value="5">37" LCD TV</option> <option value="6">42" LCD TV</option> <option value="7">37" Plasma TV</option> <option value="8">42" Plasma TV</option> <option value="9">46" Plasma TV</option> <option value="10">50" Plasma TV</option> <option value="11">54" Plasma TV</option> <option value="12">58" Plasma TV</option> <option value="13">Wall Bracket</option> <option value="14">Home Cinema System</option> <option value="15">Bluray Home Cinema System</option> <option value="16">DVD Recorder</option> <option value="17">DVD Player</option> <option value="18">DVD Portable</option> <option value="">Bluray Recorder</option> <option value="">Bluray Player</option> <option value="">Bluray Portable</option> <option value="">Projector</option> <option value="">37" LCD TV</option> <option value="">42" LCD TV</option> <option value="">Personal Video Recorder (PVR)</option> <option value="">3D Technology</option> <option value="">Upright Cleaner</option> <option value="">Cylinder Cleaner</option> <option value="">DECT Phone</option> <option value="">DECT Answer Phone</option> <option value="">Washing Machines</option> <option value="">Tumble Dryers</option> <option value="">Dishwashers</option> <option value="">Fridge-Freezers</option> <option value="">Freezers</option> <option value="">Refridgerators</option> <option value="">Microwave (Solo)</option> <option value="">Microwave (Grill)</option> <option value="">Microwave Combination</option> <option value="">Kettles</option> <option value="">Toasters</option> <option value="">Irons</option> <option value="">Breadmakers</option> <option value="">Microsystems</option> <option value="">Minisystems</option> <option value="">CD, Radio and Cassette Players</option> <option value="">Pure Radios</option> <option value="">Dimplex Fires</option> <option value="">Convector Heaters</option> <option value="">Fan Heaters</option> <option value="">Mens Shavers/Grooming</option> <option value="">Ladies Shavers/Beauty</option> <option value="">Straighteners</option> <option value="">Epilators</option> <option value="">Stylish Cameras</option> <option value="">Super Zoom Cameras</option> <option value="">SD Camcorders</option> <option value="">HD Camcorders</option> <option value="">HDD Camcorders</option> <option value="">Bluray Discs</option> <option value="">DVD Discs</option> <option value="">Leads</option> <option value="">Mini DV Tapes</option> <option value="">SD/SDHC/SDXC Cards</option> </select> <span id="productInfo">Please choose a Product Title!</span> </div> <div> <label for="price">Price</label> <input id="price" name="price" type="text" /> <span id="priceInfo">Please enter a Price!</span> </div> <div> <label for="image">Image</label> <input style="font-size:13px;" class="file" name="image" type="file" /> <span id="imageInfo">Please choose an Image!</span> </div> <div> <label for="message">Description</label> <textarea id="description" name="description" cols="" rows=""></textarea> </div> <div> <input id="send" name="send" type="submit" value="Send" /> </div> </form> </div> </body> </html> This is the other page - validation.php <?php function validateModel($model){ //if it's NOT valid if(strlen($model) < 4) return false; //if it's valid else return true; } function validatePrice($price){ //if it's NOT valid if(is_numeric($price) == '') return false; //if it's valid else return true; } function validateProduct($product){ //if it's NOT valid if(($product)=='please_select') return false; //if it's valid else return true; } function validateImage($image){ //if it's valid $allowed = array('image/gif', 'image/jpeg', 'image/jpg', 'image/png'); if(in_array($_FILES['image']['type'], $allowed)) return true; //if it's NOT valid else return false; } function validateDescription($description){ //if it's NOT valid if(strlen($description) < 10) return false; //if it's valid else return true; } ?> Any help? Hi folks, I am having a problem with the following code. it has worked for me for quite some time in many other websites but for some unknown reason it is giving me an error. - this is part of the header for opencart 1.5.1 but it should have nothing to do with it... Error: Notice: Undefined index: product_id in /home/content/42/78114/html/clients/sitename/catalog/view/theme/otp501/template/common/header.tpl on line 16 Line 16: $p_code = intval($_GET['product_id']); Code: [Select] <?php // Get Product Code From URL $p_code = intval($_GET['product_id']); // Return Product Code and Select $details = "SELECT * FROM oc_product_description WHERE product_id=($p_code)"; $SQ_query = mysql_query($details); $detail = mysql_fetch_array($SQ_query); $smalldesc = $detail['description']; $metadescription=substr($smalldesc, 12, 100); ?> <title>CO Name: <?php echo $title; ?> </title> <META NAME="Description" CONTENT="<?php echo $title; ?> - <?php echo $metadescription; ?>"> <META NAME="Keywords" CONTENT="<?php echo $title; ?>, keyword, keyword, keyword, keyword"> <META NAME="author" content="My Name"> <META NAME="copyright" content="CO name"> <meta http-equiv="pragma" content="no-cache"> <META NAME="language" content="en-us"> <META NAME="rating" content="General"> <META name="robots" content="index,follow"> <META NAME="revisit-after" content="7 Days"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href='http://fonts.googleapis.com/css?family=Delius+Swash+Caps' rel='stylesheet' type='text/css'> Hello, forgive me for this question in advance. I have looked all day for a fix to this and nothing I have come across has resolved this. My host upgraded to the most recent PHP several months ago and since it has thrown errors on certain scripts. I have gotten tired of looking at them and haven't been able to find a fix on my own so here I am. I am getting the below error.
Notice: Undefined index: mode in /home4/mesquiu0/public_html/NSDisplay/NSStorms-include.php on line 38
if ($_REQUEST['mode'] == 'expired') { // We only want the expired storms $filetoRead = $expiredfile; $arraytoUse = $Expired; } else { $filetoRead = $stormfile; $arraytoUse = $Active; }I am pretty sure it needs an inset call but not sure how to go about formatting that as I have done with the others errors I have come across. Any suggestions to this error? -Thanks! I have been using an application that was working fine using php 5.6.39 but I have to update my version of php to 7.x and am trying to fix the issues relating to that conversion. I am currently running into this error message: Notice: Undefined index: sqNum_00 in C:\usbwebserver865\root\superbowlLV\signup.php on line 23 The block of code that this refers to is as follows: if ( isset($_REQUEST['sqSelect_Submit']) ) { $SQ=0; $SQcount = 100; for ($i=0;$i<$SQcount;$i++) { if ($i<10) { $SQarray[$i] = $_POST["sqNum_0$i"]; } //This is line 23 referenced in the error message else { $SQarray[$i] = $_POST["sqNum_$i"]; } if ( isset($SQarray[$i]) ) { $SQ++; echo $SQarray[$i]." "; echo ('<input type="hidden" name="square_'.$SQ.'" value="'.$SQarray[$i].'">'); echo ('<input type="hidden" name="sqTotal" value="'.$SQ.'">'); if ( $SQ == 10 ) { echo "<p>Maximum of 10 Squares per selection</p>"; break; } // limit to 10 } } Any assistance provided would be greatly appreciated. BTW, this error message is repeated for the 100 squares in the grid such as sqNum_01 etc. although it always refers to the same line number. hi i am carl i am quite new to php and i am haveing a problem with my code this is the error Code: [Select] Notice: Undefined index: action in sale.php line 30I was on the understanding if it could not find " ?action" it would go to default witch it does but it thoughs up the error sorry for my spellings thanks in advance carl Code: [Select] <style type="text/css"> <!-- body,td,th { color: #FF0000; } body { background-color: #CCFFFF; } a:link { color: #FF0000; } a:visited { color: #FF0000; } --> </style> <script type="text/javascript" language="JavaScript1.2" SRC="scripts/stm31.js"></script> <?php session_start(); include 'mainmenu.php'; print "<table width=100% height='400' border='0'> <tr> <td width='700' valign=top >"; #if(isset($_GET["action"])) switch($_GET['action']) { case 'sale': sale(); break; case 'wanted': wanted(); break; case 'free': free(); break; case 'add' : add(); break; default: home(); break; } function home() { print "<center><h3>for sale,wanted or free items</h3><br /> here you can view <br /> <a href='sale.php?action=sale'>Items For Sale</a><br /> <a href='sale.php?action=wanted'>Items Wanted</a><br /> <a href='sale.php?action=free'>Free items</a><br /> <a href='sale.php?action=add'>Post items</a><br /> "; } function sale() { print "<center><table BORDER=4 CELLPADDING=2 CELLSPACING=2 WIDTH=95% valign=top> <tr style='background:gray'> <th>Item name</th> <th>Description</th> </tr></center><br />"; include "config.php"; $result= mysql_query("SELECT * FROM sale ")or die(mysql_error()); while($r = mysql_fetch_array($result)) { print "<tr> <td><center>{$r['iname']}</center></td> <td>{$r['dec']}</td> </tr>"; } print "</table>"; } function wanted() { print "<center><table BORDER=4 CELLPADDING=2 CELLSPACING=2 WIDTH=95% valign=top> <tr style='background:gray'> <th>Item Wanted</th> <th>Description</th> </tr></center><br />"; include "config.php"; $result= mysql_query("SELECT * FROM wanted ")or die(mysql_error()); while($r = mysql_fetch_array($result)) { print "<tr> <td><center>{$r['iname']}</center></td> <td>{$r['dec']}</td> </tr>"; } print "</table>"; } function free() { print "<center><table BORDER=4 CELLPADDING=2 CELLSPACING=2 WIDTH=95% valign=top> <tr style='background:gray'> <th>Free Item </th> <th>Description</th> </tr></center><br />"; include "config.php"; $result= mysql_query("SELECT * FROM free ")or die(mysql_error()); while($r = mysql_fetch_array($result)) { print "<tr> <td><center>{$r['iname']}</center></td> <td><center>{$r['dec']}</center></td> </tr>"; } print "</table>"; } function add() { print " <center><table BORDER=4 CELLPADDING=2 CELLSPACING=2 WIDTH=95% valign=top> <tr style='background:gray'> <th>Item posting</th> </tr></center><br />"; include "config.php"; print "<th>Your Name: <br /> <form method='post' action='pros.php'> <input type='text' name='name' size='35' /> <br /> Your Email:<br /> <input type='text' name='email' size='35' /> <br /> <select name='type' size='1'> <option value='sale'>For Sale</option> <option value='wanted'>Wanted</option> <option value='free'>Items for free</option> </select> <br /><br /> Item Name: <br /> <textarea name='iname' rows='2' cols='15'></textarea><br /> Message: <br /> <textarea name='dec' rows='4' cols='40'></textarea> <br /> <img src='captcha.php'><br /> Enter the code above: <input type='text' name='captcha'> <input type='submit' value='post' /></th>"; } print "</table>"; print " </tr> </table></td> </tr> </table>"; ?> Hi I have some php webpages that where working OK. Now this error has suddenly appeared: Notice: Undefined index. REQUEST_URI in menu.php on line 4 Here are the first 6 lines from menu.php: Code: [Select] <div style="float: left; width: 150px; margin-left: 0; padding-left: 0;"> <ul style="margin-left: 0; padding-left: 0; color: white;"> <li class="accordionButton style="color: red;"<?php if (basename($_SERVER["REQUEST_URI"]) == "index.php") { echo " active_link"; } ?>"> <a class="rfpMenuBtn" style="color: grey;font-size: 11pt;" href="index.php">Home</a></li> Also when I click on a link from the above menu.php the php include files for the link are not parsed only the html in the actual file that I link to appears nothing from the php include files. I've recently tried to do some cleaning up on my pc in the process I ran "Free Windows Registry Repair 2.5" and SpeedUpMyPC 2011. I don't know if one of these caused the problem. My OS is Windows XP I've installed xampp with php for windows. I'm using HTML-Kit to write php pages. Another change I've noticed is that before the clean up, to preview pages in HTML-Kit I would first have to run: iisreset -stop , then start Apache from xampp control panel. Now the preview works with and without running iisreset and starting Apache. Some-one from another forum suggested I run print_r($_SERVER) this is the output I received: Code: [Select] Array ( [ALLUSERSPROFILE] => C:\Documents and Settings\All Users.WINDOWS [APPDATA] => C:\Documents and Settings\davidm.DAVID\Application Data [CLASSPATH] => .;C:\Program Files\QuickTime\QTSystem\QTJava.zip [CommonProgramFiles] => C:\Program Files\Common Files [COMPUTERNAME] => DAVID [ComSpec] => C:\WINDOWS\system32\cmd.exe [FP_NO_HOST_CHECK] => NO [HOMEDRIVE] => C: [HOMEPATH] => \Documents and Settings\davidm.DAVID [INCLUDE] => d:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\include\ [LIB] => d:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Lib\ [LOGONSERVER] => \\DAVID [NUMBER_OF_PROCESSORS] => 2 [OS] => Windows_NT [Path] => C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;D:\Program Files\Samsung\Samsung PC Studio 3 [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH [PROCESSOR_ARCHITECTURE] => x86 [PROCESSOR_IDENTIFIER] => x86 Family 6 Model 23 Stepping 6, GenuineIntel [PROCESSOR_LEVEL] => 6 [PROCESSOR_REVISION] => 1706 [ProgramFiles] => C:\Program Files [QTJAVA] => C:\Program Files\QuickTime\QTSystem\QTJava.zip [SESSIONNAME] => Console [SystemDrive] => C: [SystemRoot] => C:\WINDOWS [TEMP] => C:\DOCUME~1\DAVIDM~1.DAV\LOCALS~1\Temp [TMP] => C:\DOCUME~1\DAVIDM~1.DAV\LOCALS~1\Temp [USERDOMAIN] => DAVID [USERNAME] => davidm [USERPROFILE] => C:\Documents and Settings\davidm.DAVID [VS71COMNTOOLS] => d:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\ [VS90COMNTOOLS] => d:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\ [windir] => C:\WINDOWS [__COMPAT_LAYER] => EnableNXShowUI [PHP_SELF] => [REQUEST_TIME] => 1315219257 ) PHP Notice: Undefined index: REQUEST_URI in menu.php on line 14 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 19 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 24 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 29 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 34 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 39 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 45 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 50 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 55 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 60 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 65 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 70 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 75 PHP Notice: Undefined index: REQUEST_URI in menu.php on line 81 This is all Chinese to me and I'm English. I'm a complete php novice. Any help greatly appreciated. Thanks David errors shown below cant understand why its not defined???? Notice: Undefined index: username in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 4 Notice: Undefined index: name in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 5 Notice: Undefined index: surname in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 6 Notice: Undefined index: password in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 7 Notice: Undefined index: email in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 8 Notice: Undefined index: contact in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 9 save_failed Code: [Select] <!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> <title>User Register</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="stylesheet1.css"/> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <script type="text/javascript" src="forms.js"></script> <script type="text/javascript" src="saveUser1.js"></script> </head> <body> <center> <div style="width:280pt;height:350pt;border:5px solid #FFFFFF;"> <div id= "logo1"><img src="images/FINALlogo.jpg" width="60" height="50" /></div> <form id="user_details" action="userRegProcess.php" method="post"> <h1>User Registration form</h1> <legend> Enter Detail Below</legend> <br /> <table> <fieldset> <tr><td width="241"><label for="name">Username</label> <tr><td><input type="text" name="username"/></tr></td> <tr><td><label for="name">Name </label> <tr><td><input type="text" name="name"/></tr></td> <tr><td><label for="name">Surname</label> <tr><td><input type="text" name="surname" width="200"/></tr></td> <tr><td><label for="name">Enter password</label> <tr><td><input type="text" name="password" width="200"/></tr></td> <tr><td><label for="name">Email Address</label> <tr><td><input type="text" name="email" width="250"/></tr></td> <tr><td><label for="name">Contact</label> <tr><td><input type="text" name="contact" width="250"/></tr></td> <tr><td><button type="button" onclick="processUserDetails();">Submit</button></td></tr> <div style="clear:both;"></div> </fieldset> </table> </form> </div> Code: [Select] <?php // Retrieve form data $username = $_POST['username']; $name = $_POST['name']; $surname = $_POST['surname']; $password = $_POST['password']; $email = $_POST['email']; $contact = $_POST['contact']; if (!$username || !$name || !$surname || !$Password || !email || !contact) { echo "save_failed"; return; } $db = array( 'host' => 'vega.soi.city.ac.uk', 'login' => 'abhr428', 'password' => '040010722', 'database' => 'abhr428', ); $link = @mysql_connect($db['host'], $db['login'], $db['password']); if (!$link) { echo "save_failed"; return; } mysql_select_db($db['database']); // Clean variables before performing insert $clean_username = mysql_real_escape_string($username); $clean_name = mysql_real_escape_string($name); $clean_surname = mysql_real_escape_string($surname); $clean_password = mysql_real_escape_string($password); $clean_email = mysql_real_escape_string($email); $clean_contact = mysql_real_escape_string($contact); // Perform insert $sql = "INSERT INTO users (usr_id, usr_name, usr_surname, usr_password, usr_email, usr_contact) VALUES ('{$clean_username}', {$clean_name}, '{$clean_surname}', '{$clean_password}', '{clean_email}', '{clean_contact}')"; if (@mysql_query($sql, $link)) { echo "success"; @mysql_close($link); return; } else { echo "save_failed"; @mysql_close($link); return; } ?> Hi There, I'm a NEWBY PHP and am following this tutorial "http://youtu.be/U1jFhFM4l8o". I've copied his code almost exactly but with my credentials as I have designed my database a little differently, but I don't see why his page loads fine yet for all of my $variable lines I get this error: "Notice: Undefined index: submit in C:\xampp\htdocs\indiemunity\register.php on line 7". I'm presuming I need to open the connection to the database on each page accessing it and close it at the end, which is why I have the include where the tutorial doesn't. I just don't get this? Am I declaring the variables incorrectly? Possibly due to different version of PHP? I'm running XAMPP/PHPMyAdmin/SQL. MY CODE BELOW ------------------------------------------------------------------------------------------------------------------------------- <?php include_once 'dbconnect.php'; echo "<h1>Register</h1>"; // Form Data $submit = $_POST['submit']; $useremail = $_POST['useremail']; $username = $_POST['username']; $userpassword = $_POST['userpassword']; $userpasswordcheck = $_POST['userpasswordcheck']; ?> <html> <form action='register.php' method='POST'> <table> <tr> <td> Email: </td> <td> <input type='text' name='useremail'> </td> </tr> <tr> <td> Username: </td> <td> <input type='text' name='username'> </td> </tr> <tr> <td> Password: </td> <td> <input type='password' name='userpassword'> </td> </tr> <tr> <td> Repeat: </td> <td> <input type='password' name='userpasswordcheck'> </td> </tr> </table> <p> <input type='submit' name='submit' value='Register'> </form> </html> ------------------------------------------------------------------------------------------------------------------------------- THE ERROR ------------------------------------------------------------------------------------------------------------------------------- Notice: Undefined index: submit in C:\xampp\htdocs\indiemunity\register.php on line 7 Notice: Undefined index: useremail in C:\xampp\htdocs\indiemunity\register.php on line 8 Notice: Undefined index: username in C:\xampp\htdocs\indiemunity\register.php on line 9 Notice: Undefined index: userpassword in C:\xampp\htdocs\indiemunity\register.php on line 10 Notice: Undefined index: userpasswordcheck in C:\xampp\htdocs\indiemunity\register.php on line 11 ------------------------------------------------------------------------------------------------------------------------------- Hope you can help. I'm sure it's something simple. Thanks in advance, Jeff jnst17@tpg.com.au - Interested in helping me further as well? Email me Help me solve in error Notice: Undefined index: ch1 in C:\wamp\www\latest\library\bookdb.php on line 3 It comes when i uncheck any checkbox Thank U in advance I am getting the following error when I try to run my php script: Notice: Undefined index: MAX(Date) in D:\Pricing\EasyPHP-5.3.9\www\FT9 05-16-12.php on line 21 The most recent date is: The most recent or MAX Date should be returned after the echo statement "The most recent date is:" Here is my code: Code: [Select] <?php $conn=odbc_connect("XXX","xxx|xxx","xxx"); if (!$conn) { exit("Connection Failed: " . $conn); } // Get a specific result from the "FT9_FUEL_TAX_PRICE_LINES" table $query =("SELECT ItemNumber,MAX(Date) FROM 'FT9_FUEL_TAX_PRICE_LINES' WHERE ItemNumber = 'E-10 NL GAS'AND TableCode = 'CITA' GROUP BY 'ItemNumber'"); $result = odbc_exec($conn, $query) or die(odbc_errormsg()); // keeps getting the next row until there are no more to get while($row=odbc_fetch_array($result)) { // Print out result echo "The most recent date is: " .$row['MAX(Date)']; echo "<br />"; } ?> Can anyone help me with this? Any help would be much appreciated. Notice: Undefined index: username in C:\wamp\www\LogInSystem\login.php on line 2 Notice: Undefined index: password in C:\wamp\www\LogInSystem\login.php on line 3 Help me to change this error Code: [Select] <?php $username = $_POST['username']; ERROR IS IN THIS LINE $password = $_POST['password']; ERROR IS IN THIS LINE if ($username&&$password){ $connect = mysql_connect ("localhost", "root","") or die ("could not connect"); mysql_select_db ("login") or die ("could not find db"); } else { die ("Please enter username and password!");} ?> if($_GET['task']=='del') { $id=$_GET['id']; $name=$_GET['new_image']; mysql_query('delete from tbl_gallery where id="'.$id.'"' ); unlink ($name); } hi i am getting this message on a isset and not sure how to fix it Notice: Undefined index: option in Code: [Select] <?php $option = $_GET['option']; $path = 'option/'; $extension = '.php'; if ( preg_match("#^[a-z0-9_]+$#i",$option) ){ $filename = $path.$option.$extension; include($filename); } ?> hope someone can help, please. |