For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > June 2007 > Newbie 2









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie 2
Reggie

2007-06-29, 7:00 pm

Notice: Undefined variable: username in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/create_entry.php on line 11

Notice: Undefined variable: password in /home/fhlinux169/c/
clashoff.co.uk/user/htdocs/create_entry.php on line 11

Ive got a new error message please help.Am trying to setup userlogin
on my website.

This is the code:

<?php

mysql_connect("localhost","root") or
die ("Could not connect to database");
mysql_select_db("user") or
dir ("Could not select database");

if ($_POST['submit'] == "Register")
{
$query = "insert into users
(username, password) values ('$username', '$password')";
mysql_query($query) or
die (mysql_error());
?>
<h3>You are now registered</h3>
<a href="index.html">Go back to main page</a>
<?php
}
else
{
print("not registered");
}
?>

chaghri

2007-06-29, 7:00 pm

I think after the line below,
> if ($_POST['submit'] == "Register")

you should get the inputs into $username and $password variables from
post array as follows:
$username = $_POST['whatevertheinputfieldname'];
$password = $_POST['whatevertheinputfieldname'];

On Jun 30, 12:52 am, Reggie <joelregisfo...@hotmail.com> wrote:
> Notice: Undefined variable: username in /home/fhlinux169/c/
> clashoff.co.uk/user/htdocs/create_entry.php on line 11
>
> Notice: Undefined variable: password in /home/fhlinux169/c/
> clashoff.co.uk/user/htdocs/create_entry.php on line 11
>
> Ive got a new error message please help.Am trying to setup userlogin
> on my website.
>
> This is the code:
>
> <?php
>
> mysql_connect("localhost","root") or
> die ("Could not connect to database");
> mysql_select_db("user") or
> dir ("Could not select database");
>
> if ($_POST['submit'] == "Register")
> {
> $query = "insert into users
> (username, password) values ('$username', '$password')";
> mysql_query($query) or
> die (mysql_error());
> ?>
> <h3>You are now registered</h3>
> <a href="index.html">Go back to main page</a>
> <?php}
>
> else
> {
> print("not registered");}
>
> ?>



Reggie

2007-06-30, 7:59 am

On 29 Jun, 15:06, chaghri <cagri.balke...@gmail.com> wrote:
> I think after the line below,> if ($_POST['submit'] == "Register")
>
> you should get the inputs into $username and $password variables from
> post array as follows:
> $username = $_POST['whatevertheinputfieldname'];
> $password = $_POST['whatevertheinputfieldname'];
>
> On Jun 30, 12:52 am, Reggie <joelregisfo...@hotmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
> - Show quoted text -


hi thank for that.just a few more question.Where do i need to put

> $username = $_POST['whatevertheinputfieldname'];
> $password = $_POST['whatevertheinputfieldname'];


in my code an also where would i get my input file from.

this is the code for the input file.where would the input file name
be?
<html>
<head>
<h2>
User Registration
</h2>
<form method=post action="create_entry.php">
</head>
<body>
<b>
<br>
Username
<br>
</b>
<input type=text size=15 name=username>
<br>
<b>
UserPassword
</b>
<br>
<input type=password size=15 name=password>
<br>
<input type=submit name=submit value="Register">
<input type=reset name=reset value="Clear">
</form>
</body>
</html>

thanks

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com