Jump to content

ryanmetzler3

Members
  • Posts

    77
  • Joined

  • Last visited

Everything posted by ryanmetzler3

  1. I submitted my site to yahoo and Google. it was showing up in both search engines. Now it has disappeared from yahoo/bing. It was there before and would consistently come up #1 if I searched the URL. I made a few changes to the meta tags but reverted back to the original when it disappeared. I even resubmitted the site to yahoo/bing and it's still gone. What happened?
  2. I have the following html form: $form = "<div id='forms'><form action='login.php' method='post'> <table class='forms'> <td>Username:</td> <td><input type='text' name='user'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'/></td> </tr> <td></td> <td><input type='submit' name='loginbtn' value='Login'/></td> </tr> <tr> <td><a href='register.php'>Register</a></td> <td><a href='forgotpass.php'>Forgot Password?</a></td> </tr> </table> </form> </div>"; It is inside an if/else statement. And you notice I have it set to the php variable "form". The whole form floats left on my webpage. I want to put a small text ad to the right of it, but not on a new line. I have the JS ad saved to a file called smallad.php. So I was going to include "smallad.php"; inside a <td></td> tag in one of the rows of the form. But that does not work. Any ideas?
  3. I have not been able to find this on YouTube or the internet surprisingly. Anyways I got a simple select form here. I was not real sure where to put "name" and "value" tags. Anyways here it is: <html> <head> </head> <body> Select Your School: <form method="post"> <select> <option value="LCCC">Lorain County Community College</option> <option value="CSU">Cleveland State University</option> <input type="submit" value="Submit" /> </select> </form> </body> </html> How can I use PHP to parse to a new page based on their selection? For example if they choose LCCC then it will go to "lccc.php" or if they choose CSU it will go to "csu.php"?
  4. I have this code that queries a DB and spits out results. But I have 147 results so far and counting. How can I change this code to echo maybe 20 a page? Also it displaying photos. So how can I make the results random? I don't want users to have to click through the first 3 pages of old results they have already seen if they revisit the site. <?php require 'connect2.php'; $sql = mysql_query("SELECT imagelocation FROM store"); while ($row = mysql_fetch_array($sql)) { $imgurl = $row['imagelocation']; echo "<img id='all' src=$imgurl>"; } ?> I have tried ORDER BY RANDOM() and LIMIT with the sql but it only got me so far. I can't figure out how to break it to multiple pages and the random function did not work with my code. Any guidance would be awesome!!
  5. I have a mysql table named store. In that table there are the following rows: name, date, location, and imagelocation. Right now I have this code: @$term = $_POST['term']; $sql = mysql_query("select * from store where name = '$term'"); $numberofrows=mysql_num_rows($sql); while ($row = mysql_fetch_array($sql)) { $imgurl = $row['imagelocation']; echo "<img id='uploadstyle' src=$imgurl>" . "<br/>"; Basically the user inputs a name into the form on the site and it displays the 'imagelocation' associated with that name. How can I write some MYSQL to select everything in the 'imagelocation' column and display it?
  6. Thanks for the suggestion. It was the strangest thing. I swear it was working fine and I did not change anything. Then it stopped working and I was messing with it for hours. Then I finally just reverted back to the original before I was about to go to bed and it works fine? Some kind of which craft for sure.
  7. Thanks for the suggestion. I modified the location because my server uses shared hosting. I did not really understand why but they said you need to change your session_save_path to a file in your directory to avoid problems. I got it working again. It was the strangest thing. I swear it was working fine and I did not change anything. Then it stopped working and I was messing with it for hours. Then I finally just reverted back to the original before I was about to go to bed and it works fine? Some kind of which craft for sure.
  8. I have a website that runs using sessions. When the login page is submitted it starts a session and defines a username and user id. Then I have the following code pasted at the top of every page: session_save_path('/home/users/web/b2719/ipg.trackyourgraffiticom/cgi-bin/tmp'); session_start(); $username = $_SESSION['username']; $userid = $_SESSION['userid']; it was working fine and I did not change a thing but now when I log in, it logs me out immediately. So I did this: session_save_path('/home/users/web/b2719/ipg.trackyourgraffiticom/cgi-bin/tmp'); session_start(); ini_set("display_errors", "1"); error_reporting(-1); $username = $_SESSION['username']; $userid = $_SESSION['userid']; Just to see what errors came out. It says this: Notice: Undefined index: username in /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/includelog.php on line 6 Notice: Undefined index: userid in /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/includelog.php on line 7 Any ideas? because I can't figure out why that would make it not work.
  9. I have a website that uses sessions to keep a user logged in. It works fine on my home desktop, and laptop. I went to the college library today and tried to log in. It logs me in, and then as soon as I navigate to another page I am no longer logged in. It works on both IE and Chrome at home. It works on neither browser at school. An ideas?
  10. I was attempting to do it on my own once I saw the errors. I just figured I would post them in case anyone was very familiar with this. For example I could solve this problem in 3 minutes now for someone else instead of the hour it took me. But thanks for the hint.
  11. It gave me a whole mess of errors. Here they are Warning: session_start(): open(/var/php_sessions/sess_2b20e85a7fb0622645b0db32fe7ac672, O_RDWR) failed: No such file or directory (2) in /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/includelog.php on line 4 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/index.php:9) in /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/includelog.php on line 4 Notice: Undefined index: username in /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/includelog.php on line 5 Notice: Undefined index: userid in /hermes/bosoraweb068/b2719/ipg.trackyourgraffiticom/includelog.php on line 6 Warning: Unknown: open(/var/php_sessions/sess_2b20e85a7fb0622645b0db32fe7ac672, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/php_sessions) in Unknown on line 0 Here is also the includelog.php file it refers to. Basically this is the login form you see in the top right corner of webpages. It is supposed to detect if you logged in, then either welcome you or otherwise display a login form. <?php session_start(); error_reporting(E_ALL^ E_NOTICE); $username = $_SESSION['username']; $userid = $_SESSION['userid']; ?> <html> <head> <?php if ($username && $userid) { echo "Welcome <b>$username</b>!"; echo "</br><a href='logout.php'> Logout</a>"; } else { $form = "<div id='form'><form action='login.php' method='post'> <table> <tr> <td>Username:</td> <td><input type='text' name='user'/></td> <td>Password:</td> <td><input type='password' name='password'/></td> <td></td> <td><input type='submit' name='loginbtn' value='Login'/></td> </tr> </table> </form></div>"; echo "$form"; } ?> </head> <body> </body> </html>
  12. I have a site with users and they stay logged in using sessions. I just moved my site from WAMP to a remote server. I can successfully log in, but as soon as you navigate to another page you are logged out. The session closes I am guessing. The only thing I changed was the mysql_connect functions because I could no longer use "localhost" or "root". But I tested the mysql_connect functions and they are not giving errors and work fine. So I literally changed next to nothing. Why would my sessions not work all of a sudden?
  13. it means your query is failing because it is expecting to get some value and it is receiving nothing.
  14. I'm sorry I am extremely new to php and this is the first website I have ever made. Can you elaborate on what you mean by that? I never had to specify which user was associated with a session when using WAMP.
  15. try this instead require ('bind.php');
  16. I have a site with users. Basically you register and then when you log in it starts a session. It worked fine when I wrote it running it on WAMP. Now it is on a hosted server and it logs you out automatically as soon as you go to the next page after logging in. I assume the session is closing. Here is the session heading that I put on every page. any idea what is wrong? <?php session_start(); error_reporting(E_ALL^ E_NOTICE); $username = $_SESSION['username']; $userid = $_SESSION['userid']; ?> Here is my login page that starts the session <?php session_start(); error_reporting(E_ALL^ E_NOTICE); $username = $_SESSION['username']; $userid = $_SESSION['userid']; ?> <html> <head> <title>Login</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="main.css" media="screen" /> </head> <body> <div id='content'> <div style="clear: both;"></div> <?php include "header.php"; include "menu.php"; echo "<center><h2>Login</h2></center>"; if (isset($_POST['loginbtn']) or ($username && $userid)) {} else{echo "<right><p>Welcome back! Sign in here.</p></right>";} if ($username && $userid) { echo "You are already logged in as <b>$username</b>"; echo "<br/>Not " . $username . "? <a href='logout.php'>Logout</a>"; } else { $form = "<div id='forms'><form action='login.php' method='post'> <table class='forms'> <td>Username:</td> <td><input type='text' name='user'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'/></td> </tr> <td></td> <td><input type='submit' name='loginbtn' value='Login'/></td> </tr> <tr> <td><a href='register.php'>Register</a></td> <td><a href='forgotpass.php'>Forgot Password?</a></td> </tr> </table> </form></div>"; } if ($_POST['loginbtn']) { $user = $_POST['user']; $password = $_POST['password']; if ($user) { if ($password) { require ("connect.php"); $password = md5(md5("R4E2M0".$password."R4E2M0")); $query = mysql_query("SELECT * FROM user WHERE username='$user'") or die (mysql_error()); $numrows = mysql_num_rows($query); if ($numrows ==1) { $row = mysql_fetch_assoc($query); $dbid= $row['id']; $dbuser= $row['username']; $dbpass = $row['password']; $dbactive = $row['active']; if ($password == $dbpass) { if ($dbactive == 1) { // set session info $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; echo "<font color='green'>You have been logged in as <b>$dbuser</b>. <a href='member.php'>Click Here</a> to go to the member page.</a></font>"; } else { echo "<font color='red'>You must activate your account to login. $form</font>"; } } else { echo "<font color='red'>You did not enter the correct password. $form</font>"; } } else { echo "<font color='red'>The username you entered was not found.$form</font>"; } mysql_close(); } else { echo "<font color='red'>You must enter your password . $form</font>"; } } else { echo "<font color='red'><p>You must enter your username . $form</font>"; } } else{ echo $form; } ?> </div> <?php include 'footer.php'; ?> <div style="clear: both;"></div> <center><font size="2">Be sure to take all photos intended for this site from public property or from property you have permission to access. This site in no way encourages illegal graffiti.</font></center> </body> </html>
  17. I will try to further explain my question. I have no problems with my log in script that I wrote, it works. When I go to localhost/login.php it tells me that I am logged in or allows me to log in. But what kind of if statement can I write into the index.php (homepage) to display either that the user is logged in or that they need to log in. For example on Youtube it displays your username on the top right corner if you are logged in. Or if you are not it displays a link to log in. This probably seems like a dumb question, but I just learned how to create and register users from a tutorial and don't have a complete understanding of sessions. I don't know what the purpose of the following block of code was: <?php error_reporting(E_ALL^ E_NOTICE); session_start(); $username = $_SESSION['username']; $userid = $_SESSION['userid']; ?>
  18. I'm building this site which allows users to register and log in. There will be a monthly give away for the best photo upload. The purpose of users is to know the email address corresponding to the winning photo. But I want all features of the site available to everyone. People who are not registered just wont be entered into the giveaway when they upload. That being said, how can I simply display on the homepage their username if they are logged in, or display the log in form otherwise. Here is my log in script below. <?php error_reporting(E_ALL^ E_NOTICE); session_start(); $username = $_SESSION['username']; $userid = $_SESSION['userid']; ?> <html> <head> </head> <body> <?php if ($username && $userid) { echo "You are already logged in as <b>$username</b>"; echo "<br/>Not " . $username . "? <a href='logout.php'>Logout</a>"; } else { $form = "<form action='login.php' method='post'> <table> <tr> <td>Username:</td> <td><input type='text' name='user'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password'/></td> </tr> <tr> <td></td> <td><input type='submit' name='loginbtn' value='Login'/></td> </tr> <tr> <td><a href='register.php'>Register</a></td> <td><a href='forgotpass.php'>Forgot Password?</a></td> </tr> </table> </form>"; } if ($_POST['loginbtn']) { $user = $_POST['user']; $password = $_POST['password']; if ($user) { if ($password) { require ("connect.php"); $password = md5(md5("R4E2M0".$password."R4E2M0")); $query = mysql_query("SELECT * FROM user WHERE username='$user'"); $numrows = mysql_num_rows($query); if ($numrows ==1) { $row = mysql_fetch_assoc($query); $dbid= $row['id']; $dbuser= $row['username']; $dbpass = $row['password']; $dbactive = $row['active']; if ($password == $dbpass) { if ($dbactive == 1) { // set session info $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; echo "You have been logged in as <b>$dbuser</b>. <a href='member.php'>Click Here</a> to go to the member page.</a>"; } else { echo "You must activate your account to login. $form"; } } else { echo "You did not enter the correct password. $form"; } } else { echo "The username you entered was not found.$form"; } mysql_close(); } else { echo "You must enter your password . $form"; } } else { echo "You must enter your username . $form"; } } else{ echo $form; } ?> </body> </html>
  19. It turns out my table name was just user instead of users. That is where programming can be frustrating haha. Thanks for the help mate.
  20. Well basically my html form is at the bottom of the code. Then I just use the $_Post function to get what was input. And then a bunch of if statements to check if you are entering a legit email, duplicate usernames etc etc. Line 50 is the final if statement and it should register the user. But it keeps spitting this error at me: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Swapezee\register.php on line 33. It reads this error for line 33, 36, and 48 so basically anywhere num_rows is used. There is no new user in the DB so the error is effecting the functionality of the program. Any idea how to fix this? <?php error_reporting(E_ALL^ E_NOTICE); ?> <html> <head> </head> <body> <?php if ($_POST['registerbtn']) { $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser) { if ($getemail) { if ($getpass) { if ($getretypepass) { if ($getpass === $getretypepass) { if ( (strlen($getemail) >= 7) && (strstr($getemail,"@")) && (strstr($getemail, ".")) ) { require("connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 0) { $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_num_rows($query); if ($numrows == 0) { $password = md5(md5("R4E2M0".$password."R4E2M0")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ( '','$getuser','$password','$getemail','1','$code','$date' )"); $query = mysql_query("SELECT * FROM users WHERE username ='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1) { echo "Thanks your account has been created!"; } else { $errormsg = "An error has occured. Your account was not created."; } } else { $errormsg = "There is already a user with that email."; } } else { $errormsg = "There is already a user with that username."; } mysql_close(); } else { $errormsg = "You must enter a valid email address to register."; } } else { $errormsg = "Your passwords did not match."; } } else { $errormsg = "You must retype your password to register."; } } else { $errormsg = "You must enter your password to register."; } } else{ $errormsg = "You must enter your email to register."; } } else { $errormsg = "You must enter your username to register."; } } echo "$form"; $form = "<form action='register.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value'$getuser'/></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value'$getemail'/></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value=''/></td> </tr> <tr> <td>Re-type Password:</td> <td><input type='password' name='retypepass' value=''/></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register!'/></td> </tr> </form>"; echo "$form"; ?> </body> </html>
  21. Here is my html form and my php code. It is supposed to check if any of the forms have not been filled and echo a message if they have not. Then process the registration if they have. But it seems to ignore the blank spots. If I don't fill in fields it just processes the blank registration anyways. Where did I go wrong? <?php include ('config.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $firstname = mysql_real_escape_string($_POST['firstname']); $lastname = mysql_real_escape_string($_POST['lastname']); $email = mysql_real_escape_string($_POST['email']); if (!isset($username) || !isset($password) || !isset($firstname) || !isset($lastname) || !isset($email) ) { echo "You did not fill out the required fields."; } else { $query = mysql_query("SELECT * FROM users WHERE username = '$username'"); $rows = mysql_num_rows($query); if ($rows > 0) { die("Username taken!"); } else { $user_input = mysql_query("INSERT INTO users (username, password, firstname, lastname, email) VALUES ('$username','$password','$firstname','$lastname','$email')"); echo("Succesfuly Registered!"); } } } ?> <html> <head> <title>Register</title> </head> <body> <form action="register.php" method="post"> First Name: <input type="text" name="firstname"><br/> Last Name: <input type="text" name="lastname" /><br/> Email: <input type="text" name="email" /><br/> Username: <input type="text" name="username" /><br/> Password: <input type="password" name="password"/><br/> <input type="submit" value="Register!"/> </form> </body> </html>
  22. I will show you my code real quick to start: Here is the registration form and script. <?php include ('config.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $firstname = mysql_real_escape_string($_POST['firstname']); $lastname = mysql_real_escape_string($_POST['lastname']); $email = mysql_real_escape_string($_POST['email']); if (empty($username)) { echo("You have to fill in an username!"); } else { if(empty($password)){ echo ("You have to fill in a password!"); } else { $query = mysql_query("SELECT * FROM users WHERE username = '$username'"); $rows = mysql_num_rows($query); } if ($rows > 0) { die("Username taken!"); } else { $user_input = mysql_query("INSERT INTO users (username, password, firstname, lastname, email) VALUES ('$username','$password','$firstname','$lastname','$email')"); echo("Succesfuly Registered!"); } } } ?> <html> <head> <title>Register</title> </head> <body> <form action="register.php" method="post"> First Name: <input type="text" name="firstname"><br/> Last Name: <input type="text" name="lastname" /><br/> Email: <input type="text" name="email" /><br/> Username: <input type="text" name="username" /><br/> Password: <input type="password" name="password"/><br/> <input type="submit" value="Register!"/> </form> </body> </html> Here is the login form and script: <?php include ("config.php"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string(md5($_POST['password'])); $query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $query_rows = mysql_num_rows($query); if($query_rows > 0) { $user_data = mysql_fetch_array($query); echo ("Succesfull Login!"); session_start(); $_SESSION['user'] = "$user_data"; } else { echo ("Username and/or password incorrect"); } } if (isset($_SESSION['user'])) { echo "Welcome {$_SESSION['user']['username']}"; } ?> <html> <head> <title>Login</title> </head> <body> <form action="login.php" method="post"> Username: <input type="text" name="username" /><br/> Password: <input type="password" name="password"/><br/> <input type="submit" value="Login!"/> </form> </body> </html> I am having two problems. When I hit login the very last if statement from the login code is supposed to echo a welcome message back out to the user with their username. But no matter the username it always just says "Welcome A". I am totally stumped on that. That is my first question. Here is my other general question. Here is my site s-w-a-p-e-z-e-e(dot)com (take the junk out, I just don't want this showing up in search engines). When a person logs in I hope to be able to display their username above the picture in the top right of my site pages. Also when they upload a photo I want their username to be injected into the database with their photo. I am guessing you need to use sessions to do this. I am teaching myself to program so be kind haha. Thanks so much anyone who can help!
  23. I had this site once and it just was not getting anywhere so I deleted it. But I still owned the domain and had paid for hosting. So I programmed a new site and used the same domain. My new site is a totally different topic and all the files from the old site are deleted off the server. But if I search the domain name in google is still shows links with titles that had to do with the old site. And when you click on them it takes you to the new sit but it looks all messed up. How do I get this garbage out of their indexes?
  24. I understand pretty much everything you have going there. But this very last if statement I have a question on: if(isset($_SESSION['user'])) { echo "Welcome {$_SESSION['user']['username']}"; }[/php] I tried editing the code to match what you have outlined and it works. But when it runs this if statement it echos "Welcome A". I have no idea where this "A" is coming from. I made my username Metzler when I registered and my password 456.
×
×
  • 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.