jenna Posted May 9, 2009 Share Posted May 9, 2009 How to create form that displays submited text in it self? its like i loged in from from that form, entered my username there, and next time i come my username is already there and i only need to enter password. Quote Link to comment Share on other sites More sharing options...
fabrydesign Posted May 9, 2009 Share Posted May 9, 2009 After you validate their information in your login script, add setcookie('username',$username,time()+60*60*24*30); // $username being their username and then on your form, add: <input name="login" value="<?php if(isset($_COOKIE['username')){ echo $_COOKIE['username']; } ?>" /> Quote Link to comment Share on other sites More sharing options...
jenna Posted May 10, 2009 Author Share Posted May 10, 2009 <?php $form = $_POST['form']; if($_GET['cookie'] == 'new'){ setCookie('cookie', 2 ); header('Location: '.$_SERVER['PHP_SELF']); }elseif($_GET['cookie'] == 'del'){ setCookie('cookie'); header('Location: '.$_SERVER['PHP_SELF']); } if($_COOKIE['cookie'] != null){ echo 'Cookie exists!<br> <a href="'.$_SERVER['PHP_SELF'].'?cookie=del">Delete Cookie</a><br>'; }else{ echo 'No cookie!<br> <a href="'.$_SERVER['PHP_SELF'].'?cookie=new">New Cookie</a><br>'; } ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post"><input name="form" value="<?php if(isset($_COOKIE['cookie'])){ echo $_COOKIE['cookie']; } ?>" /><input name="form" type="hidden" value=""> <a href="<?php $_SERVER['PHP_SELF'] ?>?cookie=new">New or Chance</a></form> now how can i submit both form and .$_SERVER['PHP_SELF'].'?cookie=new at the same time ? Quote Link to comment 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.