PHP Form Which posts onto a website.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hassan
Forum Newbie
Posts: 1
Joined: Mon Mar 13, 2006 7:57 am

PHP Form Which posts onto a website.

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post 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:
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post 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.
Post Reply