Page 1 of 1

Notice: Undefined variable: submit in

Posted: Fri Jan 23, 2004 11:12 pm
by teamct2k
I looking for alittle help im new at this. I'm getting a error message --> Notice: Undefined variable: submit in e:\apache group\apache\htdocs\create_entry.php on line 12

-----------
sign.php - is the signup page doesn't get me any errors.
----------
<body>

<h2>Sign my Guest Book!!!</h2>
<form method=post action="create_entry.php">
<b>Name:</b>
<input type="text" size="40" name="name">
<br>
<b>Location:</b>
<input type="text" size="40" name="location">
<br>
<b>Email:</b>
<input type="text" size="40" name="email">
<br>
<b>Home Page URL:</b>
<input type="text" size="40" name="url">
<br>
<b>Comments:</b>
<textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea>
<br>
<input name="$submit" type="submit" id="submit" value="submit">
<input type="reset" name="reset" value="Start Over">
</form>
</body>

-----------------------------------------------------------

---------------------
create_entry.php - this is the page giving me the error on line "12"
---------------------
09) <?php
10) include("dbconnect.php");
11)
12) if ($submit == "submit")
13) {
14) $query = "insert into guestbook
15) (name, location, email, url, comments) values
16) ('$name','$location','$email','$url','$comment')";
17) mysql_query($query) or
18) die (mysql_error());
19)
20)?>
21)<h2>Thanks!!</h2>
22)<h2><a href="view.php">View My Guest Book!!!</a></h2>
23)<?php
24)}
25)else
26){
27)include("sign.php");
28)}
29)?>

Posted: Fri Jan 23, 2004 11:21 pm
by Illusionist
in your sign.php change the name of your submit button to submit, not $submit

Posted: Fri Jan 23, 2004 11:27 pm
by teamct2k
Illusionist wrote:in your sign.php change the name of your submit button to submit, not $submit
I have tried that but still geting the same error message.

Posted: Fri Jan 23, 2004 11:39 pm
by Illusionist
try changing the submit == submit line to :

Code: Select all

if (isset($_POST['name'])) {

Posted: Sat Jan 24, 2004 3:29 am
by microthick
Or along the lines of what Illusionist said:

if (isset($_POST['submit']) && $_POST['submit'] == "submit") {

}

Posted: Sat Jan 24, 2004 6:13 am
by teamct2k
thx guy it worked but im getting a different error now but I will try to find the proplem now. thx for the help.

Re: Notice: Undefined variable: submit in

Posted: Sun Jan 25, 2004 10:47 am
by teamct2k
I found the problem. array name was wrong lol

// error
error was here!!! (16) ('$name','$location','$email','$url','$comment')";
// error

//correct- had forgotten the (s)
(16) ('$name','$location','$email','$url','$comments')";
//correct- had forgotten the (s)
teamct2k wrote:I looking for alittle help im new at this. I'm getting a error message --> Notice: Undefined variable: submit in e:\apache group\apache\htdocs\create_entry.php on line 12

-----------
sign.php - is the signup page doesn't get me any errors.
----------
<body>

<h2>Sign my Guest Book!!!</h2>
<form method=post action="create_entry.php">
<b>Name:</b>
<input type="text" size="40" name="name">
<br>
<b>Location:</b>
<input type="text" size="40" name="location">
<br>
<b>Email:</b>
<input type="text" size="40" name="email">
<br>
<b>Home Page URL:</b>
<input type="text" size="40" name="url">
<br>
<b>Comments:</b>
<textarea name="comments" cols="40" rows="4" wrap="virtual"></textarea>
<br>
<input name="$submit" type="submit" id="submit" value="submit">
<input type="reset" name="reset" value="Start Over">
</form>
</body>



-----------------------------------------------------------

---------------------
create_entry.php - this is the page giving me the error on line "12"
---------------------
09) <?php
10) include("dbconnect.php");
11)
12) if ($submit == "submit")
13) {
14) $query = "insert into guestbook
15) (name, location, email, url, comments) values

// error
error was here!!! (16) ('$name','$location','$email','$url','$comment')";
// error

17) mysql_query($query) or
18) die (mysql_error());
19)
20)?>
21)<h2>Thanks!!</h2>
22)<h2><a href="view.php">View My Guest Book!!!</a></h2>
23)<?php
24)}
25)else
26){
27)include("sign.php");
28)}
29)?>