n00b question ?!

Codes here !

Moderators: macek, egami, gesf

border20
New php-forum User
New php-forum User
Posts: 32
Joined: Tue Jan 28, 2003 10:19 am
Location: Québec
Contact:

n00b question ?!

Postby border20 » Tue Jan 28, 2003 10:48 am

........
Last edited by border20 on Wed Jan 29, 2003 2:15 pm, edited 2 times in total.

border20
New php-forum User
New php-forum User
Posts: 32
Joined: Tue Jan 28, 2003 10:19 am
Location: Québec
Contact:

forgot

Postby border20 » Tue Jan 28, 2003 10:58 am

I also get the folloowing error when I press the submit button

You don't have permission to access /<br /><b>Notice</b>: Undefined variable: PHP_SELF in <b>c:/program files/apache group/apache/htdocs/form_demande_action2.php</b> on line <b>27</b><br /> on this server.

But i should have permission since i can successfully read from the database through a similar connection.

User avatar
Joan Garnet
Moderator
Moderator
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars
Contact:

Postby Joan Garnet » Tue Jan 28, 2003 3:32 pm

Use this code, it works:

Code: Select all

<html>
<body>
<?php
if ($HTTP_POST_VARS["submit"]) { // LINE 16
   $db = mysql_connect("localhost", "e_volution", "e_volution");
   mysql_select_db("mydb",$db);
   $sql = "INSERT INTO demande_action (field1,field2,field3) VALUES (".$HTTP_POST_VARS["name"].",".$HTTP_POST_VARS["email"].",".$HTTP_POST_VARS["website"].")";
   $result = mysql_query($sql);
   echo "Your data has been added to the database: NAME: ".$HTTP_POST_VARS["name"].", EMAIL: ".$HTTP_POST_VARS["email"].", WEBSITE: ".$HTTP_POST_VARS["website"]."";
}else{
?>
   <form method="post" action="<?php $PHP_SELF ?>">
   <p>
   Write your name:<br>
   <input type="text" name="name"> <br>
   Write your email:<br>
   <input type="text" name="email"> <br>
   Write your website:<br>
   <input type="text" name="website"> <br>
   <input type="Submit" name="submit" value="insert into database!"> <br>
   </form>
<?php
}//end of else
?>
</body>
</html>

I hope it helped!


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron