Jump to content
Killersites Forums

Successful login variable not working


billperrotta
 Share

Recommended Posts

There is no row for any users I am trying to create, even though the db is telling me I am registered.

 

I am lost, It would be nice if this just worked. I saw some downloadable free php scripts for logons.

 

But not sure those include mysql. I will probably look for a downloadable script for file uploading.

 

What do you suggest? I would like to get this working soon.

 

May not be able to get over that rainbow because there are no instructions to create the mysql db for those.

Link to comment
Share on other sites

How about this... Send me all your current files (a .ZIP file is probably easiest, if you know how to do that), which I believe would include:

 

-- login.php

-- register.php

-- mysql.php (you can blank out your DB details, I won't need them)

-- a dump of your current database, which you can get by logging in to PHPMyAdmin, selecting your database, and going to the "Export" tab. Just save the MySQL code PHPMyAdmin generates in a text file.

 

I can take a look and fix things if necessary. I imagine that your register script isn't working for some reason, and the easiest way for me to fix that is to have the files/db and play with it myself. If the register file isn't working, none of the rest will work.

 

Email: ben [at] falkencreative.com

Link to comment
Share on other sites

How about this... Send me all your current files (a .ZIP file is probably easiest, if you know how to do that), which I believe would include:

 

-- login.php

-- register.php

-- mysql.php (you can blank out your DB details, I won't need them)

-- a dump of your current database, which you can get by logging in to PHPMyAdmin, selecting your database, and going to the "Export" tab. Just save the MySQL code PHPMyAdmin generates in a text file.

 

I can take a look and fix things if necessary. I imagine that your register script isn't working for some reason, and the easiest way for me to fix that is to have the files/db and play with it myself. If the register file isn't working, none of the rest will work.

 

Email: ben [at] falkencreative.com

 

I sent them to ben [at] falkencreative.com

Link to comment
Share on other sites

OK, I've taken a look at things. Here's the corrected register.php page. Replace what you have with this:

 

<?php

include ('mysql.php');

if (isset ($_POST['submit'])) 
{
$username = mysql_escape_string($_POST['username']);
$password = mysql_escape_string(sha1($_POST['password']));

if (!empty ($username) && !empty ($password)) 
{
	mysql_query("INSERT INTO users (username, user_password, user_regdate) VALUES ('$username', '$password', 'time()')");
	echo 'you are now registered!';
}
else
{
 	echo 'you must enter a username and a password!';
}
}
else
{
echo '<form action="register.php" method="post">
Username: <input type="text" name="username" /><br />
Password: <input type="password" name="password" /><br />
<input type="submit" name="submit" value="Register" />
</form>';
}

?>

 

I had to update the mysql_query line so that it added to the database correctly -- you were missing a closing ")" and needed single quotes around the variables for it to work.

 

Once you've updated this page, visit it and create a new user. Then open the PHP page have I had you create which shows the contents of the 'users' table, and make sure there is a row for the new user in the table. Assuming a row shows up -- it should, this worked fine for me -- then visit login.php and log in.

Link to comment
Share on other sites

Thanks those small corrections are in valuable and it works.

 

Now question? How to I insert an html link into members.php or login.php.

So that if users that have user accounts I want to link them to another page that will allow them to upload files.

I assume I will put all the other important links in index.htm.

I plan on trying another tut I found later to create a php file uploader.

One weird thing I found login.php stops users without accounts but members.php seems to welcome anyone.

Link to comment
Share on other sites

Now question? How to I insert an html link into members.php or login.php.

So that if users that have user accounts I want to link them to another page that will allow them to upload files.

I assume I will put all the other important links in index.htm.

 

There are a couple ways to do this... Probably the simplest is to have one central members page, and then choose which content to show based on who they are:

 

members.php

<?php // check to make sure user is logged in, if not, redirect them
   session_start();
   if (!isset($_SESSION['loggedin'])) { header("location: login.php"); } ?>

   ...regular html all clients can see here...

<?php    
   if ($username == "admin") { ?> ...HTML only admin user can see...  <?php } 
   else if ($username == "client1") { ?> ...HTML only admin client1 can see...  <?php } 
   else if ($username == "client2") { ?> ...HTML only admin client2 can see...  <?php }
?>

   ... regular html all clients can see here...

 

You would need to change your login page to redirect users to this page after they log in:

 

if (mysql_num_rows ($sql) > 0) 
{
   $_SESSION['loggedin'] = true;
   $_SESSION['username'] = $username;
   header("location: members.php"); 
}

 

One weird thing I found login.php stops users without accounts but members.php seems to welcome anyone.

Take a look at the code I posted above -- that should fix it if you are having issues. Your version of members.php seemed to work fine for me, though there was an error that appeared if the user wasn't logged in saying that the if statement was checking a variable that didn't exist.

Link to comment
Share on other sites

Alternately, you could set up individual html pages for each of your clients, and then change your login.php function to redirect users to the correct page:

 

login.php

if (mysql_num_rows ($sql) > 0) 
{
   $_SESSION['loggedin'] = true;
   $_SESSION['username'] = $username;

   if ($username == "admin") { header("location: admin-home.php");  } 
   else if ($username == "client1") { header("location: client1-home.php"); } 
   else if ($username == "client2") { header("location: client2-home.php"); }
}

Link to comment
Share on other sites

Then redirect users once they log in:

 

Edit your login.php file to redirect users to the members page rather than showing a "logged in" message

if (mysql_num_rows ($sql) > 0) 
{
   $_SESSION['loggedin'] = true;
   $_SESSION['username'] = $username;
   header("location: members.php"); 
}

 

And make this change to your members page:

 

<?php 
   // check to make sure user is logged in, if not, redirect them
   session_start();
   if (!isset($_SESSION['loggedin'])) { header("location: login.php"); } 
?>

...regular html all clients can see here, including links, images, etc...

Link to comment
Share on other sites

Then redirect users once they log in:

 

Edit your login.php file to redirect users to the members page rather than showing a "logged in" message

if (mysql_num_rows ($sql) > 0) 
{
   $_SESSION['loggedin'] = true;
   $_SESSION['username'] = $username;
   header("location: members.php"); 
}

 

And make this change to your members page:

 

<?php 
   // check to make sure user is logged in, if not, redirect them
   session_start();
   if (!isset($_SESSION['loggedin'])) { header("location: login.php"); } 
?>

...regular html all clients can see here, including links, images, etc...

 

Not to sound stupid but I am used to adding links with Kompozer.

What is the tag to create the link? I just want to create a local html file ie "reportuploads.html" then create a link on the members.php page to it.

 

<html>reportuploads.html<html> ? By the way the last changes work like charm. just need to know how to insert links to other web pages into members.php

Edited by billperrotta
Link to comment
Share on other sites

That will show a paragraph (because of the <p> tags) with the text "Welcome to get a beef?".

 

I was under the impression that you know a bit of HTML, but it seems like you might want to take a look at the sample videos here that will get you started with HTML basics: http://killersites.com/web-design/

 

Tizag (http://www.tizag.com/htmlT/) and W3 Schools (http://www.w3schools.com/html/default.asp) also have useful HTML related tutorials and articles.

Link to comment
Share on other sites

That will show a paragraph (because of the <p> tags) with the text "Welcome to get a beef?".

 

I was under the impression that you know a bit of HTML, but it seems like you might want to take a look at the sample videos here that will get you started with HTML basics: http://killersites.com/web-design/

 

Tizag (http://www.tizag.com/htmlT/) and W3 Schools (http://www.w3schools.com/html/default.asp) also have useful HTML related tutorials and articles.

 

Now I'm semi up and running how would I create a form like this? I copied the fields from ripoff report.com. I want to be able to create a report with these options see below. It is a complaint form. This whole project has been for a friends consumer reports website.

 

 

 

* File a Report

 

Company or Individual Information

Company or Individual Information

Report Title and Category

Report Title and Category

Write your Report

Write your Report

Add Photos

Add Photos

Submit your Report

Submit your Report

Company or Individual you are reporting

 

All the information in Step 1 is on the Company or Individual you are reporting.

YOU ARE NOT reporting your personal information here.

Name of Company or Individual you are reporting:

 

- If you have more than one Company or Individual named in your report, or if the company goes by more

than one name (AKA's), put the other names in the "Other Name's" box

Name of Company

or Individual:

Aditional names (AKA's):

(optional)

Address of Company or Individual you are reporting:

 

- You must enter either a physical street address and/or a web address.

 

- You may enter both, BUT If the Company or Individual is on the Internet and only on-line based, or you

don't have a physical address, you MUST enter their Web address

 

Street Address: physical (street) address only, city and state go below

 

Web Address:

City, State, Zip Code, and Country of Company or Individual you are reporting:

 

- Multiple cities can be entered for more than one location.

 

- If the Company or Individual is on the Internet and only on-line based, and you have entered the Web

address: the city, zip code, and country boxes can be left blank. Enter "Internet" in the State box.

City:

State/Province: Select Internet if online only.

Zip Code: (optional)

Country:

Phone, FAX, and e-mail address of Company or Individual you are reporting:

 

- This information is not required, but they are good tools for sympathetic Consumers to let the Company or

Individual know how they feel about what they did to you and will only help your situation.

 

- This information may also be helpful to other victims reading your Ripoff Report.

 

- The more information you provide, the better.

Fax:

Phone:

E-mail address:

 

Ripoff Report

 

* Home

* File a Report

* Consumer Resources

* Search

* Link to Ripoff Report

 

 

 

* Privacy Policy

* Terms of Service

* FAQ

* About Us

* Contact Us

* Why Ripoff Report will not release author information!

 

 

 

* Thank You Emails!

* Corporate Advocacy Program: How to repair your business reputation.

* Ed Magedson - Ripoff Report Founder

 

 

 

* Want to sue Ripoff Report?

* Donate to our Legal Defense

 

Copyright © 1998-2010, Ripoff Report. All rights reserved.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...