6 Replies - 1282 Views - Last Post: 05 August 2010 - 05:21 AM Rate Topic: ***-- 2 Votes

#1 jaydscape  Icon User is offline

  • New D.I.C Head

Reputation: -10
  • View blog
  • Posts: 21
  • Joined: 25-June 10

How do I make a login PHP

Posted 27 July 2010 - 03:07 PM

Hey, I'm making a site and I need to make a login and registration for my users.
I also need to make it so that if they want to download they have to login, however I don't know how to make the link to know whether the person is logged in or not.
One more thing I need something to keep track of each users history(So when they buy a download they get one free...With this staying the same if they log out.

Any idea how to do this?
Tutorials?
Thanks!
---I Suck at PHP and MSQL!---

Is This A Good Question/Topic? 0
  • +

Replies To: How do I make a login PHP

#2 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: How do I make a login PHP

Posted 27 July 2010 - 03:29 PM

I'll answer these questions briefly.

View Postjaydscape, on 27 July 2010 - 09:07 PM, said:

Hey, I'm making a site and I need to make a login and registration for my users.
I also need to make it so that if they want to download they have to login, however I don't know how to make the link to know whether the person is logged in or not.


You can do this by using session variables.

Quote

One more thing I need something to keep track of each users history(So when they buy a download they get one free...With this staying the same if they log out.


You can use a database to store user's history.
Was This Post Helpful? 2
  • +
  • -

#3 jaydscape  Icon User is offline

  • New D.I.C Head

Reputation: -10
  • View blog
  • Posts: 21
  • Joined: 25-June 10

Re: How do I make a login PHP

Posted 27 July 2010 - 03:59 PM

The first one helped thanks...I just searched how to make a database..I'm using CPanel and was kinda confused, but I think i got it now...At least you gave an answer.
Was This Post Helpful? 0
  • +
  • -

#4 Stoutn  Icon User is offline

  • New D.I.C Head

Reputation: -5
  • View blog
  • Posts: 18
  • Joined: 07-June 10

Re: How do I make a login PHP

Posted 27 July 2010 - 05:54 PM

I can point you in the direction for the login system, but that about as far as my knowledge goes at the moment.

The login would just be a html form that uses the (filtered) data to query a mysql database. If the username/password combo is correct, set a session to show the user as logged in. Showing/not showing fields, such as the login form, is as simple as using the session. If the session exsists, then echo Username and/or download links in place of the form, if not, show something else. Also dont forget a logout link, that triggers an unset of the session :)
Was This Post Helpful? 0
  • +
  • -

#5 Longblob  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 12-December 09

Re: How do I make a login PHP

Posted 28 July 2010 - 08:50 PM

Maybe this can help

first create login form :
<form name=”form1″ method=”post” action=”loginpro.php”>
<table width=”200″ border=”0″>
<tr>
<td colspan=”2″><div align=”center”>Halaman Login </div></td>
</tr>
<tr>
<td>Username</td>
<td><input type=”text” name=”username”></td>
</tr>
<tr>
<td>Password</td>
<td><input type=”password” name=”password”></td>
</tr>
<tr>
<td><input type=”submit” name=”Submit” value=”Login”></td>
<td> </td>
</tr>
</table>
</form>


second create login process page for loginpro.php

<?
session_start();$server = “localhost”; 
$username = “root”; 
$password = “”; 
$db_name = “tutorial”; 
mysql_connect($server,$username,$password) or DIE(“failed connection”);
mysql_select_db($db_name) or DIE(“there is no database name !!”);
$login = mysql_query(“select * from login where (username = ‘” . $_POST['username'] . “‘) and (password = ‘” . md5($_POST['password']) . “‘)”,$db);
$rowcount = mysql_num_rows($login);
if ($rowcount == 1) {
$_SESSION['username'] = $_POST['username'];
header(“Location: mainpage.php”);
}
else
{
header(“Location:./index.php”);
}
?>


may this help

This post has been edited by Longblob: 28 July 2010 - 08:51 PM

Was This Post Helpful? 0
  • +
  • -

#6 josh06  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 139
  • Joined: 27-October 06

Re: How do I make a login PHP

Posted 04 August 2010 - 10:51 AM

Please comply with DIC's policy and show us some code so we can see that you are actually trying to do this yourself and just need some help.

Just to point you in the right direction, you'll need to use Session variables for that.
E.g.
session_start();
$_SESSION['authorised'] = true;

etc. You'll probably have to look into protecting Session data to prevent session hi-jacking seeing as people will be paying on this site.

With the history, just have a table in a database maybe called purchases and when someone buys something their user id and the id of the download goes in this database and when they visit the download again it will check the database and see that they have already got it.

Hopefully helped a little..
Was This Post Helpful? 0
  • +
  • -

#7 isuckatC++  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 04-May 09

Re: How do I make a login PHP

Posted 05 August 2010 - 05:21 AM

Well if u haven't even started one yet here is a tutorial on how to create a good login system A better login system.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1