Jump to content

samona

Members
  • Posts

    232
  • Joined

  • Last visited

    Never

Everything posted by samona

  1. you didnt close your quotations on the die() function on line 37. Use the code below and try again. <?php include "connect.php"; if(isset($_POST['submit'])) { $username=$_POST['username']; $password=$_POST['password']; $email=$_POST['email']; if(strlen($username)<1) { print "You did not enter a username."; } else if(strlen($password)<1) { print "You did not enter a password."; } else { $insert="Insert into users (username,password,email) values('$username','$password','$email')"; mysql_query($insert) or die("Could not insert comment"); } } ?>
  2. How about right before the <?php tag? Just add another <option value="">Example</>
  3. When you use for loops you would use it in the php code not the template file. And the way you would use it depends on the template class.
  4. you can't use the header() function when you have already sent output
  5. OK, I just put this on my server and ran it. Should work now. The problem was the name for the submit button you had was "Submit". I changed the form so the name of the submit button is "submit" and I included an else statement. Actually, you dont need the else statement. I'll revise it... <?php if (isset($_POST['submit'])) { // Define your username and password $post_username = trim($_POST['txtUsername']); $post_password = trim($_POST['txtPassword']); $username = "test"; $password = "admin"; if ($post_username == $username && $post_password == $password) { header("Location: welcome.php"); } else { header("Location: error.php"); } } //If the user hasn't pressed the submit button then display the form ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="submit" value="Login" /></p> </form>
  6. Try the code below. I changed the if statement to AND instead of OR <?php if (isset($_POST['submit'])) { // Define your username and password $post_username = $_POST['txtUsername']; $post_password = $_POST['txtPassword']; $username = "test"; $password = "test"; if ($post_username == $username && $post_password == $password) { header("Location: mainlogin.php"); } else { header("Location: mainlogin.php"); } } //If the user hasn't pressed the submit button then display the form ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form>
  7. For example <?php if (isset($_POST['submit']) { // Define your username and password $post_username = $_POST['txtUsername']; $post_password = $_POST['txtPassword']; $username = "someuser"; $password = "somepassword"; if ($post_username == $username && $post_password == $password) { session_start(); $_Session["login_name"] = $username; header("Location:next_page"); } else { header("Location:error_page"); } } //If the user hasn't pressed the submit button then display the form <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form> Then the next page would be <?php session_start(); if (!isset($_SESSION["login_name"])) { //revert them to error page if they have not logged in. header("Location:error_page.php); } //Contine with rest of your code
  8. I agree with deskit. If you want a login system than sessions are the way to go.
  9. Sorry, I forgot a paranthesis. Change it to this if (isset($_POST['submit'])) { // Define your username and password
  10. Try the following <?php if (isset($_POST['submit']) { // Define your username and password $post_username = $_POST['txtUsername']; $post_password = $_POST['txtPassword']; $username = "someuser"; $password = "somepassword"; if ($post_username == $username || $post_password == $password) { header("Location:next_page"); } else { header("Location:error_page"); } } //If the user hasn't pressed the submit button then display the form <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form>
  11. Oh, you want to go to another page if the password is correct. Sorry! Ummm give me a few minutes.
  12. Try the code below and let me know if it works. <?php // Define your username and password $username = "someuser"; $password = "somepassword"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { header("Location:page_to_display_error"); else { ?> <h1>Login</h1> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p><label for="txtUsername">Username:</label> <br /><input type="text" title="Enter your Username" name="txtUsername" /></p> <p><label for="txtpassword">Password:</label> <br /><input type="password" title="Enter your password" name="txtPassword" /></p> <p><input type="submit" name="Submit" value="Login" /></p> </form> <? } ?>
  13. You can't output data before the header() function.
  14. I was wondering, does an application have to be written in a certain way for it to be available on a wireless network? FOr example, are there applications that don't work on wireless?
  15. I check but thats not the problem. When I mean I have to switch folders for the inbox to update I mean that it doesn't make a different if I wait 1 minute or 1 hour. The inbox updates only when i switch folders.
  16. Hi all, I have a problem with outlook using the IMAP protocol. Whenever I receive email in outlook I have to switch to another folder in order for my inbox to update. As an example, if someone sends me an email. Outlook does not contain the new email. However, when I switch to another folder and back to inbox the email will finally appear. Has anyone experienced this or know of a fix?
  17. thank you all!!!!!!!!!!!!!!!!!!!!!
  18. When I right click on the Google logo and select view image, an image containing all the images on the page gets produced instead of viewing just the Google logo. Is that CSS?
  19. Is it possible to connect one network card to two networks?
  20. Hi, This may be a stupid question, but why would you want to put the session id in the url?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.