murli800 Posted April 30, 2011 Share Posted April 30, 2011 i want to pass the information getting from the form and after storing in to the variables to a new php file ..how to pass all the value getting from the form [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/235203-passing-value-by-post-to-a-new-php-file/ Share on other sites More sharing options...
fugix Posted April 30, 2011 Share Posted April 30, 2011 whatever php file you want to send the data to...make that php file your action in your form <form method='post' action='example.php' > Quote Link to comment https://forums.phpfreaks.com/topic/235203-passing-value-by-post-to-a-new-php-file/#findComment-1208692 Share on other sites More sharing options...
murli800 Posted May 1, 2011 Author Share Posted May 1, 2011 actually i want to make a code .. AIM IS THAT TEACHER FIRST LOG IN AND THEN MARK THE ATTENDANCE step 1)TEACHER FIST LOGIN .......2)TEACHER THEN CHOOSE ONE OF TWO BUTTON IN WHICH ONE IS OF ENTRY AND OTHER FOR EXIT...3)I ALSO WANT TO USE SESSION..IN THE MAIN.PHP i want to input username and password..and then redirect the page to attendance.php...also want to include session ...HELp me [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/235203-passing-value-by-post-to-a-new-php-file/#findComment-1208993 Share on other sites More sharing options...
wildteen88 Posted May 1, 2011 Share Posted May 1, 2011 In main.php you're calling header("location:attendance.php"); after output has been sent. header() cannot be called after output has been sent to the browser. You should move this block of code in main.php <?php if(!empty($_POST['submit'])) { $username=$_POST['username']; $pwd=$_POST['pwd']; $_SESSION['user']=$username; //$_SESSION['user']; $_SESSION['pswd']=$pwd; } header("location:attendance.php"); ?> Into the same code block where you have session_start();. Use this code for main.php <?php session_start(); //include "../sabkuch/dbconnect.php"; if(isset($_POST['submit'])) { $username = $_POST['username']; $pwd = $_POST['pwd']; $_SESSION['user'] = $username; $_SESSION['pswd'] = $pwd; header("location:attendance.php"); } ?> <form name="login" method="post" action="#"> <b>ENTER YOUR DETAILS BELOW</b><br/> <hr/> USERNAME:<input name="username" type="text" value=""><br/> PASSWORD:<input name="pwd" type="password" value=""><br/> <input name="submit" type="submit" value="LOGIN"> </form> The next issue is in attendence.php, on line 16 you're calling session_destroy();. Calling this function will destroy the current session. You should only call this function in certain circumstances, such as when logging out the current user. If you leave it as is every time you go to main.php and fill in your username/password your session will always be reset. Quote Link to comment https://forums.phpfreaks.com/topic/235203-passing-value-by-post-to-a-new-php-file/#findComment-1208997 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.