Linking a site to php database

Permabanned
Joined
22 Apr 2007
Posts
1,805
I know little about php but I have uploaded my site with .php file extensions.

Primarily to somehow echo the output of form fileds to a php database.

secondly, I would like to update my 'news' pages in an easy CMS style manner.

Can anyone point me in a suitable direction to achieve this?
 
MySQL, thats what I meant. Thanks

One thing that tutorial doesnt cover (AFAICS) is how to 'Log In' to the database through a website once all the tables are set up, etc.

Any ideas?
 
?

you mean for the site to connect to the db?

Code:
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');

$dbname = 'petstore';
mysql_select_db($dbname);
?>
 
You have to create a html form (e.g. username and password) then use a MySQL query to check to see if the username and password matches the one for the user in the database.

It's a bit more complicated than that though as you'll want to validate the form fields to make sure they only allow characters that you allow in the username and password.
 
so do I essentially put both your posts together and call it admin.php or something?

Then, from the login link goes off to admin.php where you enter the details and then click Submit / Login, whatever.

What would appear on the screen then?
 
You could do it like the following:

login.html
Code:
<!-- html header -->

<!-- HTML form here with action of process.php -->

process.php
Code:
<?php 

$username = $_POST['username'];
$password = $_POST['password'];

// form validation goes here. If form validation == true then query database.

?>
 
am I over complicating this?

I just want to have a secure section on my site that I can add a news article to which then gets entered into the news page of my site.

I can live without the contacts thing to start with.

So, I've used phpmyadmin and created a table with 3 fields (ID, title, content).

I have created a MySQL db (news) and given it a username and password.

I've also created an HTML form (no action or method yet).

Just looking for some pointers now.

I guess to link to this article form, i could just use htaccess?

Thanks so far
 
Back
Top Bottom