Page 1 of 1

PHP Form Which posts onto a website.

Posted: Mon Mar 13, 2006 8:12 am
by Hassan
Hiya,

I'm a bit of a PHP newbie, so forgive me if my question is a amateurist. What i'm looking to do, is create a form on PHP which outputs to a website. ie, the data entered in the form will appear on the website in a specified manner.

For example:
Say I create a form which has 2 fields, "News" and "date"...someone should be able to enter info into these 2 fields and have it appear on a website, already appropriatley formated. eg, the date would be size 10 font, and the news a size 12.

How would I go about doing this?
I have basic PHP knowledge.

Posted: Mon Mar 13, 2006 8:17 am
by Chris Corbyn
Moved to PHP Code.

To do this you'll need to understand how to read POST or GET data. You'll also need a MySQL database or some other way of storing the information.

Have a look at the PHP website at http://www.php.net/ You'll find some tutorials on there for doing the GET/POST part.

A quick and extremely basic example of handling POST data would be this:

Code: Select all

<form action="some_file.php" method="post">
Send this value to a PHP script: <input type="text" name="some_value" />
</form>
some_file.php

Code: Select all

<?php

echo $_POST['some_value'];

?>
You'll need at least a basic grasp of PHP syntax before you go on to do any database work with it ;)

Posted: Mon Mar 13, 2006 9:30 am
by a94060
d11wtq wrote:Moved to PHP Code.

To do this you'll need to understand how to read POST or GET data. You'll also need a MySQL database or some other way of storing the information.

Have a look at the PHP website at http://www.php.net/ You'll find some tutorials on there for doing the GET/POST part.

A quick and extremely basic example of handling POST data would be this:

Code: Select all

<form action="some_file.php" method="post">
Send this value to a PHP script: <input type="text" name="some_value" />
</form>
some_file.php

Code: Select all

<?php

echo $_POST['some_value'];

?>
You'll need at least a basic grasp of PHP syntax before you go on to do any database work with it ;)
after that,you would use somethnigl like

Code: Select all

while($row=mysql_fetch_array($result,MYSQL_ASSOC)) {/*this will get you the whole row and put into an array with the column names.\n Replace the date and news with real names of the columns.*/

//put the font formatting for each thing,like this

/*
echo '<font size=10>$row['date']</font><br>'
echo '<font size=12>$row['news']</font><br>'
*/
}
this will be how you can display the entries,as for getting th edata,ill leave that up to you :wink:

Posted: Mon Mar 13, 2006 1:34 pm
by nickman013
Its pretty confusing at first, but it is reallllyyyyyy easy.

Just make sure if your form method is POST then make sure that your PHP is $_POST['name']; and the same for GET.