Notice: Undefined variable: submit in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
teamct2k
Forum Newbie
Posts: 4
Joined: Fri Jan 23, 2004 11:12 pm

Notice: Undefined variable: submit in

Post 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)?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

in your sign.php change the name of your submit button to submit, not $submit
teamct2k
Forum Newbie
Posts: 4
Joined: Fri Jan 23, 2004 11:12 pm

Post 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.
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

try changing the submit == submit line to :

Code: Select all

if (isset($_POST['name'])) {
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Or along the lines of what Illusionist said:

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

}
teamct2k
Forum Newbie
Posts: 4
Joined: Fri Jan 23, 2004 11:12 pm

Post 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.
teamct2k
Forum Newbie
Posts: 4
Joined: Fri Jan 23, 2004 11:12 pm

Re: Notice: Undefined variable: submit in

Post 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)?>
Post Reply