Jump to content


php / mySQL form help


4 replies to this topic

#1 Hyprkookeez

    Young Padawan

  • Members
  • Pip
  • 49 posts
  • Location:Edmonton AB CA
  • Interests:Photoshop, HTML

Posted 20 May 2005 - 12:13 PM

I'm stuck on how to insert data into tables using forms. I looked through plenty of the tutorials, but none of them helped me =(. So now i'm wondering how do i do it.

I'm trying to make a link trader with
title, url and description. I got everything working, and i inputted the data from mysqladmin (in cpanel) but now i don't know how to add it using php.

Can anyone help me out?
(link to linktrader: http://www.hyprkooke...m/linktrade.php) If it helps you help me :ph34r:

#2 TheOne

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 20 May 2005 - 12:58 PM

Quote

I'm stuck on how to insert data into tables using forms. I looked through plenty of the tutorials, but none of them helped me =(. So now i'm wondering how do i do it.

I'm trying to make a link trader with
title, url and description. I got everything working, and i inputted the data from mysqladmin (in cpanel) but now i don't know how to add it using php.
In perl i would do something like this
sub updatedb{

$query = "INSERT INTO NameOfYourTable(Tittle, Url, Description)
          VALUES ('$tittle', '$url', '$description');";

$sth = $dbh->prepare($query);
$sth->execute() or webdb3::dberr_trap("Unable to insert into YourTableName");

$sth->finish();
$dbh->disconnect;
}


#3 Hyprkookeez

    Young Padawan

  • Members
  • Pip
  • 49 posts
  • Location:Edmonton AB CA
  • Interests:Photoshop, HTML

Posted 20 May 2005 - 01:46 PM

That's perl though and i know absolutely nothing about perl. Anyone have an example for php?

I need an example that i can use with
<form method= 'get' action= 'This Little Action Thing Here' >

#4 p0iz

    Young Padawan

  • Members
  • Pip
  • 66 posts

Posted 20 May 2005 - 02:10 PM

sure..

just use this.

<?php
if(!$_POST['submit']){
?>
<form action="#" method="post">
Title:<input type="text" name="title">
<br />
URL:
<input type="text" name="url">
<br />
Info: 
<textarea rows="3" name="info" cols="20"></textarea>
<br />
<input type="submit" name="submit" value="Trade!">

</form>
<?php
}else{
	$query = mysql_query("INSERT INTO table (title,url,info) VALUES ('$_POST[title]','$_POST[url]','$_POST[info]')");
	echo"Site added to database.";
}
?>

note, you'll need to change some stuff and you might want to make a functoin to clean up the input data to make it safer.

#5 Hyprkookeez

    Young Padawan

  • Members
  • Pip
  • 49 posts
  • Location:Edmonton AB CA
  • Interests:Photoshop, HTML

Posted 20 May 2005 - 02:33 PM

Thank you SOOOOOOOOOOOOOOOOO much! :ph34r:





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users