FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


1st timer





agentofnight
can any one help me im new to DBs, and this is my 1st script using it but i get an error on like 26 can any one help my find it
Code:
<?php

foreach($_POST as $key => $value){
   $$key= $value;
   }
//check log in
if ($name=="agentofnight" || $name=="Agentofnight" && $password=="130490"){
//check fields
   if ($msgname=="" || $msg==""){
      echo "Please go back and fill in every field.";
      echo "<BR>";
      echo "<a href=http://localhost/testing/form.html>Click Here to go back to the form</a>";
   }
echo "Welcome ";
echo "<b>";
echo $name;
echo "</b><br>";
echo "Your message was: ";
echo "<b>";
echo $msg;
echo "</b><br>";
echo "And the name of the message was: ";
echo "<b>";
echo $msgname;
echo "</b>";
//Database stuff
   if($_SERVER['submit']){
    $date=date("F d, Y");
   mysql_connect("localhost","agentofnight","130490");
   mysql_select_db("learnit");
   mysql_query("INSERT INTO mytable (id,name,msg,date,) VALUES ($id,$name,$msg,$date)");
   }

} else {
echo "Wrong name or password, please try again";
echo "<BR>";
echo "<a href=http://localhost/testing/form.html>Click Here to go back to the form</a>";
}

   



?>
Marston
.. What error are you getting? Like copy and paste the exact error message into this topic, please. Wink
agentofnight
Notice: Undefined index: submit in c:\program files\easyphp1-8\www\testing\form.php on line 27
mathiaus
im thinking of replacing
$_SERVER['submit']
with
$_POST['submit']
though viewing your form code would be helpful Wink
agentofnight
now i get

Notice: Undefined variable: id in c:\program files\easyphp1-8\www\testing\form.php on line 31
mathiaus
can you post the code for your form then please?
agentofnight
<form action="form.php" method="post" name="form">
<p>Name:
<input name="name" type="text" />
<br>
Password:
<input name="password" type="password" />
</p>
<p>Message:</p>
<p>Message Name:
<label>
<input name="msgname" type="text" id="msgname" />
</label>
</p>
<p>
<label>
<textarea name="msg" cols="60" rows="8" id="msg"></textarea>
</label>
<br />
<input name="submit" type="submit" id="submit" value="submit" />
<input name="Reset" type="reset" id="Reset" value="Reset" />
</p>
</form>
agentofnight
any idea?
mathiaus
change this line
mysql_query("INSERT INTO mytable (id,name,msg,date,) VALUES ($id,$name,$msg,$date)");

to
mysql_query("INSERT INTO mytable (id,name,msg,date,) VALUES ('',$name,$msg,$date)");

you were trying to inser the variable id when you shouldnt
make sure in your database structure that the id row is auto increase or something similar. cant think what its called at the moment sorry
agentofnight
i have finally compleated my 1st script that uses mysql
including a form,the processing file, a file that reads it.
thanx so much guys Very Happy
Related topics
my 1st community website
My first site :D:D:D
Flash Timer
1st Annual ZogDog Animation Contest
Which html editor?
Photography Assignment #1 (April 1st-15th)
XML Timer
Saints Row Demo Coming to Xbox Live on August 1st
i am selling on $3.9 for 1st year and 7.9 for the next.
JavaScript Countdown Timer Help!
kumar/war 1st person shooter with mulitplay free download
How to design a website
Triva of the Day! 1st $100, 2nd $50, 3rd $25 Prizes
Guess Team India Performance in future...?
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.