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. Link to comment https://forums.phpfreaks.com/topic/157482-username-from-cookie/ 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']; } ?>" /> Link to comment https://forums.phpfreaks.com/topic/157482-username-from-cookie/#findComment-830251 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 ? Link to comment https://forums.phpfreaks.com/topic/157482-username-from-cookie/#findComment-831080 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.