kidding? google shows a few thousand.
newbie needs help
this is a good place to start:
{this is my code when i enter info into the form fields and press submit the info does not get inserted into my database }
<?php
//connect to server and select database
$con = mysql_connect("localhost", "***", "***",);
if(!$con)
{
die ('Could not connect: ' . mysql_error());
mysql_select_db("registration", $con);
//retrieve posted info.
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
//insert into database.
$sql = "INSERT INTO newusers SET username='$username' ,
password='$password' , email='$email' ";
//display message.
if (!mysql_query($sql,$con) )
{
die('ERROR:' . mysql_error() );
}
echo "Info successfully added!";
mysql_close($con)
?>
<html>
<body>
<!-- Tutorial Description: PHP Forms -->
<form action="form_success.php" method="post">
username: <input type="text" name="username" /><br>
password: <input type="text" name="password" /><br>
email: <input type="text" name="email" /><br>
<input type="submit" value="login" />
</form>
</body>
</html>
i normally use this metod to insert
INSERT INTO
newusers
(username, password, email)
VALUES
('$username', '$password', '$email' );
does that work?
have a look at this page
that still didnt work what do u think i could be doing wrong??
what is the actual error coming up on your screen? if there is one?
do u know of a site that is for complete beginners i have been self teaching myself but i stumbled across php and its a whole another world
when i fill in the 3 form fields and click submit nothing happens just the form fields are emptied
first of all run this with data :
INSERT INTO
newusers
(username, password, email)
VALUES
('damianuser', 'damianpass', 'damian@damian.com' );
obviously with the necessary conenctions, see if that works.
When you the form is going back to the same page? or to another page? because you have placed < form action="form_success.php" > but i don't know what pages you are using?
ok have a look at this tutorial, http://www.tizag.com/phpT/examples/formex.php
you need to post the results to the same form, because you are going away from the form.
replace this line:
<form action="form_success.php" method="post">
with
<form action="<?php echo $PHP_SELF;?>" method="post">
i have my code and form on form_success.php and the action for the form is also form_success.php
mr.zo392011;11001652 wrote:do u know of a site that is for complete beginners i have been self teaching myself but i stumbled across php and its a whole another world
stay with it, it gets a whole lot easier once you understand a few basics, you will get it just keep going through, might takes hours or days figuring out problems...
ok thank you i do appreciate it theres not alot of php savvy users on here that want to help without making you feel like an ass
have you got errors tuned on?
put this on top of the page before <html> tag
<?php
ERROR_REPORTING(E_ALL);
ini_set('display_errors','On');
?>
this will help you find what's wrong with your code quickly.
mr.zo392011;11001661 wrote:ok thank you i do appreciate it theres not alot of php savvy users on here that want to help without making you feel like an ass
no worries im just a bit bored at work, you are helping me past the time haha,
i am here till 5.50pm takes me 10minutes to shut everything down lol
i put the bit of error code into the top of my page and submitted the form and still nothing happened and no error messages came up
this may be a silly question, but forgive me for asking, have you got an apache server running with PHP and Mysql?
also the error code i gave you shold be the very first thing on the page ontop of everything!
yes i have apache ...idk if its good or bad but i put in the selfphp into the action and now it says can find the file
yes the error code is on top of everything