Tuesday, 06 January 2009
   
Home arrow Tutorial  
 
Home
Supporto
Contattaci
Categorie Script
RSS Media Grabber Video & Foto Divertenti Storie di Vita (Flash) Video: Ricerca & Download Script Download Video Nazioni in Vendita Script per Sondaggi Host per File wap Script Creazione SlideShow Script PhotoCube Script "Make Confessions" Script Spartiti Chitarra Crea Smile Personalizzati URL Brevi & Sottodomini Script Gioco Hot Or Not Metti il Tuo Testo Sulle Img Host & Watermark Img Salva i Tuoi Preferiti Online Componenti Joomla Script a Basso Costo
Partners
StileGames
Php Tutorial
 
 
   
 
Add a Row to mySQL Print E-mail

Here is what we have to write in English for the processing:

  1. If submit is hit, then connect to the database

  2. Insert the values into the correct database.

  3. Get a conformation that it has been uploaded

Here it is in PHP:

<?
//initilize PHP

if($_POST['submit']) //If submit is hit
{
//then connect as user
//change user and password to your mySQL name and password
mysql_connect("localhost","user","password");

//select which database you want to edit
mysql_select_db("spoono_news");

//convert all the posts to variables:
$title = $_POST['title'];
$message = $_POST['message'];
$who = $_POST['who'];
$date = $_POST['date'];
$time = $_POST['time'];

//Insert the values into the correct database with the right fields
//mysql table = news
//table columns = id, title, message, who, date, time
//post variables = $title, $message, '$who, $date, $time
$result=MYSQL_QUERY("INSERT INTO news (id,title,message,who,date,time)".
"VALUES ('NULL', '$title', '$message', '$who', '$date', '$time')");

//confirm
echo "Query Finished";
}
?>

And that is basically all the code we have to write for the processing. Now the hard part, writing the form, which isn't really as hard as it seems. Here is what we have to write in English for the Form:

  1. If submit is NOT hit, then make the form with the action as this file itself.

  2. Create an HTML table and plug in all the information. Make sure that the "name" section of each input matches up with the processing code. For example, the "$_POST['title']" on the processing up above means one of the fields down here must me named title. The ID is left blank because its Auto-Increment.

  3. Make the Submit button, so the If-Then on this runs properly.

I hope you can understand HTML forms, as the code is fairly basic. All forms are inputs, the name field becomes the PHP post variable with a value of the value field. Here is the HTML and PHP:

<?
else
{
// close php so we can put in our code
?>
<form method="post" action="add.php">
<TABLE>
<TR>
<TD>Title:</TD>
<TD><INPUT TYPE='TEXT' NAME='title' VALUE='Random Update' size=60></TD>
</TR>
<TR>
<TD>Message:</TD>
<TD><INPUT TYPE='TEXT' NAME='message' VALUE='' size=60></TD>
</TR><br>
<TR>
<TD>name_upper:</TD>
<TD>
<SELECT NAME='who'>
<OPTION VALUE='Akash'>Akash
<OPTION VALUE='Brian'>Brian
</SELECT>
</TD>
</TR>
<TR>
<TD>date:</TD>
<TD>
<!-- You can use PHP functions to automatically get the value of date -->
<INPUT TYPE='TEXT' NAME='date' VALUE='<? echo date("M.j.y"); ?>' size=60>
</TD>
</TR>
<TR>
<TD>time:</TD>
<TD>
<!-- You can use PHP functions to automatically get the value of time -->
<INPUT TYPE='TEXT' NAME='time' VALUE='<? echo date("g:i a"); ?>' size=60>
</TD>
</TR>
<TR>
<TD></TD><br>
<TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>

<?
} //close the else statement
?>

The name is title, which matches up with $title at the top, and when you run the script, the default text is going to be post on the board and ask for help and we'll try to help you out. You can see my code that I worked on and made sure worked by right clicking and saving delete.txt.

Credit: www.spoono.com 





Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
 
Se trovi uno dei nostri operatori online, contattalo prima di comprare per usufruire di uno sconto!
Servizi
Controlla PageRank
Richiedi un Preventivo
Script Gratuiti
Installazione Script
Blog Backlinks
Login Form
Prodotti Scontati
PhotoCube
PhotoCube
$44.99
$24.99
You Save: $20.00
Add to Cart
 
Copyrighted © 2006 phppod.com