blyz Posted July 21, 2007 Share Posted July 21, 2007 Here is my script at the moment it displays a html form if the user is logged in, and displays nothing if the user is not logged in, what bit would i need to change to display text if the user is not logged in and where would i put it, i'm a complete php noob this is someone elses script, thanks. <? if(isset($_SESSION['useredit'])){ unset($_SESSION['useredit']); echo "<h1>User Account Edit Success!</h1>"; echo "<p><b>$session->username</b>, your account has been successfully updated. " ."<a href=\"login.php\">Main</a>.</p>"; } else{ ?> <h1>User Account Edit : <? echo $session->username; ?></h1> <? if($form->num_errors > 0){ echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>"; } ?> <form action="process.php" method="POST"> <table align="left" border="0" cellspacing="0" cellpadding="3"> <tr> <td>Current Password:</td> <td><input type="password" name="curpass" maxlength="30" value=" <?echo $form->value("curpass"); ?>"></td> <td><? echo $form->error("curpass"); ?></td> </tr> <tr> <td>New Password:</td> <td><input type="password" name="newpass" maxlength="30" value=" <? echo $form->value("newpass"); ?>"></td> <td><? echo $form->error("newpass"); ?></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="email" maxlength="50" value=" <? if($form->value("email") == ""){ echo $session->userinfo['email']; }else{ echo $form->value("email"); } ?>"> </td> <td><? echo $form->error("email"); ?></td> </tr> <tr><td colspan="2" align="right"> <input type="hidden" name="subedit" value="1"> <input type="submit" value="Edit Account"></td></tr> <tr><td colspan="2" align="left"></td></tr> </table> </form> <? } ?> Link to comment https://forums.phpfreaks.com/topic/61137-solved-how-would-i-go-about-adding/ Share on other sites More sharing options...
marcus Posted July 21, 2007 Share Posted July 21, 2007 If you're holding the user logged in, in a session you could just do: if($_SESSION['name']){ //show stuff logged in }else { //show you need to be logged in to view this } Link to comment https://forums.phpfreaks.com/topic/61137-solved-how-would-i-go-about-adding/#findComment-304249 Share on other sites More sharing options...
blyz Posted July 21, 2007 Author Share Posted July 21, 2007 yes i am using login sessions, could you put that snippet^ into my code plase? i really am clueless. Link to comment https://forums.phpfreaks.com/topic/61137-solved-how-would-i-go-about-adding/#findComment-304252 Share on other sites More sharing options...
jaymc Posted July 21, 2007 Share Posted July 21, 2007 Lol... its really not hard <? if($_SESSION['name']){ //COPY AND PASTE HERE EVERYTHING FOM ABOVE THAT YOU WANT TO BE DISPLAYED IF THEY ARE LOGGED IN } else { // COPY AND PASTE HERE EVERYTHING FROM ABOVE YOU WANT DISPLAYED IF THEY ARE NOT LOGGED IN } ?> Link to comment https://forums.phpfreaks.com/topic/61137-solved-how-would-i-go-about-adding/#findComment-304262 Share on other sites More sharing options...
blyz Posted July 21, 2007 Author Share Posted July 21, 2007 ok lol thanks. Link to comment https://forums.phpfreaks.com/topic/61137-solved-how-would-i-go-about-adding/#findComment-304276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.