Jump to content

Etiquette and proper use of php


sanderphp

Recommended Posts

I'm still tweaking my first ever php project and want to learn how to properly do things.

 

I have:

login.php that is just a form

checklogin.php which verifies the username and password

login_success.php where the user enters the data

add_data.php which writes the data to the table

submit_success.php which displays the entry and total miles ridden this year

 

My presumption is that I can probably do a lot of these functions in one or two php files.

 

I'm also loading stuff like this on most pages which seems really repetitive:

 

$host="localhost"; // Host name 
$username="stuff_admin"; // Mysql username 
$password="password"; // Mysql password 
$db_name="stuff_cycling"; // Database name 
$tbl_name="riders"; // Table name 

// Connect to server and select databse.
$conn = mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

 

I would guess that I should be storing the password in a file so someone couldn't just open my php files and access my db  but I haven't been able to find a tutorial on how to do that anywhere. 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/104326-etiquette-and-proper-use-of-php/
Share on other sites

$host="localhost"; // Host name

$username="stuff_admin"; // Mysql username

$password="password"; // Mysql password

$db_name="stuff_cycling"; // Database name

$tbl_name="riders"; // Table name

 

// Connect to server and select databse.

$conn = mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

 

just use include();

 

for a nice tutorial visit this.

http://www.evolt.org/PHP-Login-System-with-Admin-Features

 

good luck.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.