Drezek Posted October 11, 2009 Share Posted October 11, 2009 well im learning php and mysql i found this tutorial http://www.phpeasystep.com/workshopview.php?id=6 and i was wondering how to make the checklogin.php and main_login.php parts into the same webpage like once it sends the form information it just reloads the webpage and it registers a session and displays information from the database using the username id this is my first week into learning how to program php and mysql so feel free to educate me Quote Link to comment https://forums.phpfreaks.com/topic/177278-need-help-with-some-php-logic/ Share on other sites More sharing options...
mikesta707 Posted October 11, 2009 Share Posted October 11, 2009 quite easy <form> <!-- form stuff --> <?php if (isset($_POST['username'])){//whatever the username input field is //paste your login check stuff here } ?> you can either set the action of the form to the same page, OR just don't set an action at all. If you don't set an action on the form, the action will by default be the page of the form. the isset() checks of the post variable is set. and the only way the post variable will be set is if the user filled out the form and clicked submit. then it does the check login stuff. this is actually a very common thing for people to do Quote Link to comment https://forums.phpfreaks.com/topic/177278-need-help-with-some-php-logic/#findComment-934716 Share on other sites More sharing options...
Drezek Posted October 11, 2009 Author Share Posted October 11, 2009 very simple i have no idea why i didnt think of that thanks a bunch Quote Link to comment https://forums.phpfreaks.com/topic/177278-need-help-with-some-php-logic/#findComment-934767 Share on other sites More sharing options...
Drezek Posted October 11, 2009 Author Share Posted October 11, 2009 <?php if (isset($_POST['username']) { echo "fsaf"; } else { echo "<form name="login" method="post" action="index.php">"; echo "<input name="username" type="text" id="username">"; echo "<font color="#A4A4A4"><h3><center><bold>PASSWORD</bold></center></h3></font>"; echo "<input name="password" type="password" id="password"><br>"; echo "<center><input type="submit" name="Submit" value="Login"></form></center>"; } ?> whats wrong with this Quote Link to comment https://forums.phpfreaks.com/topic/177278-need-help-with-some-php-logic/#findComment-934776 Share on other sites More sharing options...
cags Posted October 11, 2009 Share Posted October 11, 2009 The syntax highlighting shows you exactly whats wrong, you start the echo statement with a double quote, so as soon as it encouners another double quote it thinks that string is finished you need to either swap some of the quotes to single quotes or you need to escape the double quoets. Example: echo "<form name=\"login\" method=\"post\" action=\"index.php\">"; Quote Link to comment https://forums.phpfreaks.com/topic/177278-need-help-with-some-php-logic/#findComment-934826 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.