Dreevoo.com | Online Learning and Knowledge Sharing
 
Home | FORUM | Published content on Dreevoo.com | Website User Registration in PHP
Gost
Click to view your profile
Shortcuts
Fresh topics Fresh topics
My topics My topics
Unanswered topics Unanswered topics
Forum rules Forum rules
Who is online?
Registered users: Registered users:
Guests: Guests:

 
  Website User Registration in PHP
   
   
 
 
 
USER
MESSAGE
  Click to open user profile  
29th Sep 2013, 12:00 AM
We will make a PHP web page in which we will connect to MySql database, handle user authentication and show certain data only for registered users.


Link to the content ...
 
 
  Click to open user profile  
29th Nov 2013, 4:44 AM
Hi, I have a question about the users table. Why did you used text for username and password instead of VARCHAR?
 
 
  Click to open user profile  
29th Nov 2013, 6:24 AM
TEXT is stored in the table as a pointer to the location of the actual text, while VARCHAR stores data directly in the table. So in theory VARCHAR is indeed a better choice.

But from practical point of view, the difference in performance is almost non-existant. On the other hand, for VARCHAR you need to specify maximum length. Since this is lesson for beginners, I have chosen TEXT, so that it will work in all cases.

I hope this answers your question. If you need any more info just let me know.

changed: podtalje (29th Nov 2013, 2:25 PM)
 
 
  Click to open user profile  
7th Apr 2014, 10:44 AM
When I try the code I receive:

Fatal error: Call to a member function fetch_assoc() on a non-object in D:\wamp\www\login\index.php on line 14

Same goes for the Forum with PHP and MySQL .

Can you help me please?

changed: julien gautar (7th Apr 2014, 7:45 PM)
 
 
  Click to open user profile  
7th Apr 2014, 2:48 PM
The code is failing on line $result->fetch_assoc().

The error is saying that $result is not an object. The reason for this is that it failed in the previous call which is:
$sql="select * from users where username='$username'";
$result = $db->query($sql);

So it seems there is a problem with your query to the database.

One possible reason is that the connection to the database was not successfully established. Another reason might be that tables in the database are not correct.

To solve this problem, you should first try to run the query in the phpMyAdmin to see if it returns any result.
Try using additional "echo $sql" in the code (after defining $sql variable) to see exactly what the query is.

I would also suggest that you add the following line at the top of the page after <?php
error_reporting(E_ALL);

This will show you all errors and warnings.






 
 
 
   
   
 
online learning made for people
Dreevoo.com | CONTRIBUTE | FORUM | INFO