ilight Posted September 11, 2009 Share Posted September 11, 2009 Im trying to build my own website and here is my first php script ever!! Im trying to get the input and process it in the same page. The welcome function shall ask for the input with the no. of entries and it shall load such many times the text fields for further input. I get this error when i run it Notice: Undefined index: seen in C:\wamp\www\sast.com\ded.php on line 46 and when i enter the data and all, the text fields come up but with these warnings again Notice: Undefined index: ecarray in C:\wamp\www\sast.com\ded.php on line 64 Notice: Undefined index: amtarray in C:\wamp\www\sast.com\ded.php on line 65 <?php $go = welcome(); function welcome(){ ?> <h1> Select the area, month and the no. of records you want to enter<br> </h1> <form method="post"> <select name="area" single> <option>----Area</option> <option>corp</option> <option>kgm</option> <option>yld</option> <option>mng</option> <option>rg1</option> <option>rg2</option> <option>rg3</option> <option>bhpl</option> <option>mm</option> <option>bpa</option> <option>srp</option> <option>hyd</option> </select> <select name="month" single> <option>----Month</option> <option>jan</option> <option>feb</option> <option>mar</option> <option>apr</option> <option>may</option> <option>jun</option> <option>jul</option> <option>aug</option> <option>sep</option> <option>oct</option> <option>nov</option> <option>dec</option> </select> <div> <input type="text" name="entries" value="No. of entries" onfocus="this.value=''"> </div> <br> <input type="submit" name="seen"> </form> <?php $gone = $_REQUEST["seen"]; return $gone; } if($go) getdata(); # function to load form to get empcode and amount function getdata(){ $area = $_REQUEST["area"]; $month = $_REQUEST["month"]; $entries = $_REQUEST["entries"]; for($i=0;$i<$entries;$i++) { ?> <form method="post"> <div><input type="text" name="ecarray" value="employee code" onfocus="this.value=''"</div>    <div><input type="text" name="amtarray" value="deduction amount" onfocus="this.value=''"></div>    </form> <?php $ecarray[] = $_REQUEST["ecarray"]; $amtarray[] = $_REQUEST["amtarray"]; } echo "<form><input type='submit' value='submit'/><br></form>"; } ?> Any help will be great. Sorry if this is so noobish. But i just started learning. Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/ Share on other sites More sharing options...
RussellReal Posted September 11, 2009 Share Posted September 11, 2009 php evaluates then pushes your html (what you see when you go to a website) How you're approaching this is wrong.. you're looking to push the html THEN have php 'hang' and receive the data they give to you, NOW this is impossible to do.. in order for you to do t his you'd need to create the form.. and with php 'expect' data to be sent back to the same page.. with the data you can do whatever you do with the data.. but you will not push html then get a response in the same execution of php Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/#findComment-916468 Share on other sites More sharing options...
ilight Posted September 11, 2009 Author Share Posted September 11, 2009 So I'd have to make a seperate html input form and direct that to a php script that evaluates data, right? but what if i want to do it in the same php form? sry if i missed something. can i shuffle the html code in the welcome function and make it work with a single php script with html? Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/#findComment-916482 Share on other sites More sharing options...
l0ve2hat3 Posted September 11, 2009 Share Posted September 11, 2009 error_reporting(1); Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/#findComment-916488 Share on other sites More sharing options...
ilight Posted September 11, 2009 Author Share Posted September 11, 2009 error_reporting(0); ?? starting the php with that? Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/#findComment-916494 Share on other sites More sharing options...
l0ve2hat3 Posted September 11, 2009 Share Posted September 11, 2009 well that would turn error reporting off completely... i think error_reporting(1) shows only errors Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/#findComment-916496 Share on other sites More sharing options...
ilight Posted September 11, 2009 Author Share Posted September 11, 2009 tried it. it doesnt show any errors as if there are none. thanks working fine for now Quote Link to comment https://forums.phpfreaks.com/topic/173856-undefined-index-warning-in-my-code/#findComment-916503 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.