Jump to content

traedet

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

traedet's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thx for a quick answer! The problem remains tho... I need to call the function from the form. How do i make an action that calls the function? <form action="test.php?addlunch" method="post" name="lunch"> test.php?addlunch is not right is it?
  2. Here you go: <?php $host="localhost"; $username="XXX"; $password="XXX"; $db_name="XXX"; $tbl_name="lunch"; mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $tbl_name") or die("Can't connect with table"); ?>
  3. Hi, I'm in the basic learning phase in PHP and ran into a problem two days ago... I need to make a function that $_POST to MySQL. I think i have the function working but i cant make the form call the function to submit the data to my Database! This is the function (filename is test.php) : <?php function addlunch() { $sql="INSERT INTO $tbl_name(vecka, dag, lunch1, lunch2)VALUES('$_POST[vecka]','$_POST[dag]','$_POST[lunch1]','$_POST[lunch2]')"; $result=mysql_query($sql); mysql_close(); } ?> And now the problem is to call the function to this form: <form action="test.php?addlunch" method="post" name="lunch"> <input value="<?php echo ($veckonummer); ?>" name="vecka" type="text" /><br /> <input name="dag" type="text" value="MÃ¥ndag" /><br /> <textarea name="lunch1" cols="40"></textarea><br /> <textarea name="lunch2" cols="40"></textarea> <input type="submit" value="Skicka" /><input type="reset" value="Rensa" /> </form> If anyone could take a look at it i would appreciate it!! Thx!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.