Current location: Hot Scripts Forums » Programming Languages » PHP » $php_self is not working...


$php_self is not working...

Reply
  #1 (permalink)  
Old 04-28-04, 02:50 PM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
$php_self is not working...

Hi,

I am brand new to the world of php, sql, apache, etc, but I am trying to learn and build this site. But whenever I run this script it will show the page and display the form, but above the form is says:

"Notice: Undefined index: submit in C:\Program Files\Apache Group\Apache2\htdocs\sel1.php3 on line 25"

which is the if($_POST["submit"]) line. Does anyone have any suggestions? If you do, I appreciate it very much as it will probably make my life alot easier.

Thanks!
Amber


<?php

if ($_POST["submit"]) {

// process form
$db = mysql_connect("localhost", "root");

mysql_select_db("evm",$db);

$sql = "INSERT INTO custinfo (name, address1, address2, city, state, zip, email, dname, dob, dod) VALUES ('$name','$add1','$add2','$city','$state','$zip',' $email','$decname','$dob','$dod')";

$result = mysql_query($sql);

echo "Thank you! Information entered.\n";
} else{

// display form

?>


<form class="form" action="<?php echo $_SERVER[$PHP_SELF]?>" method="POST">
<table>
<tr>
<td>
Full Name:
</td>
<td><input type="text" name="name" />
</td>
</tr>
<tr>
<td>
Address Line 1:
</td>
<td><input type="text" name="add1" />
</td>
</tr>
<tr>
<td>
Address Line 2:
</td>
<td><input type="text" name="add2" />
</td>
</tr>
<tr>
<td>
City:
</td>
<td><input type="text" name="city" />
</td>
</tr><tr>
<td>
State:
</td>
<td><input type="text" name="state" />
</td>
</tr>
<tr>
<td>
Zip Code:
</td>
<td><input type="text" name="zip" />
</td>
</tr>
<tr>
<td>
Email Address:
</td>
<td><input type="text" name="email" />
</td>
</tr>
<tr>
<td>
Deceased's Name:
</td>
<td><input type="text" name="decnam" />
</td>
</tr>
<tr>
<td>
Deceased's Date of Birth:
</td>
<td><input type="text" name="dob" />
</td>
</tr>
<tr>
<td>
Deceased's Date of Death:
</td>
<td><input type="text" name="dod" />
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Enter Information" /></td>
</tr>
</table>

</form>


<?php

}
// end if


?>
Reply With Quote
  #2 (permalink)  
Old 04-28-04, 03:09 PM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Actually

i changed line 25 to if(isset($_POST['submit'])) and it now longer shows an error.

but when i click submit now, it says i dont have permission to access /.
and it says there's an undefined index and variable in the line with $php_self in it. this line:

<form class="form" action="<?php echo $_SERVER[$PHP_SELF]?>" method="POST">
Reply With Quote
  #3 (permalink)  
Old 04-28-04, 03:26 PM
Mike343 Mike343 is offline
New Member
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
try this.

<form class="form" action="<?=$_SERVER[PHP_SELF]?>" method="POST">
Reply With Quote
  #4 (permalink)  
Old 04-28-04, 03:57 PM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
It still gives me this message when i click submit:

You don't have permission to access /
Notice: Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in C:/Program Files/Apache Group/Apache2/htdocs/sel1.php on line 43 /sel1.php on this server.

Thank you though!!
Reply With Quote
  #5 (permalink)  
Old 04-28-04, 03:59 PM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
... i put in the quotation marks and it likes php_self much better now.

but now it says all my variables are undefined.
???
Reply With Quote
  #6 (permalink)  
Old 04-29-04, 01:57 AM
nd2 nd2 is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
why not just remove the action, ?
<form class="form" method="POST">

this will submit to it's self since the action has not been set.

and it's $_SERVER['PHP_SELF']
not $_SERVER[PHP_SELF]

since PHP_SELF is not a constent or interger you cannot use it with out single or dubble quotes.
__________________
IonCMS (Coming Soon.)
http://ioncms.com
--
Ncaster (Free php/mysql cms)
http://ncaster.cjb.net
Reply With Quote
  #7 (permalink)  
Old 04-29-04, 08:54 AM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
thank you,

but now it just says parse error where it shouldnt:

$sql = "INSERT INTO custinfo (name, address1, address2, city, state, zip, email, dname, dob, dod) VALUES ('$_POST['name']','$_POST['add1']','$_POST['add2']','$_POST['city']','$_POST['state']','$_POST['zip']','$_POST['email']','$_POST['decname']','$_POST['dob']','$_POST['dod']')";

any suggestions?

this is the error, if it helps:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Group\Apache2\htdocs\sel1.php on line 31

thanks again!
amber
Reply With Quote
  #8 (permalink)  
Old 04-29-04, 09:20 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
use this:
PHP Code:

$sql "INSERT INTO custinfo (name, address1, address2, city, state, zip, email, dname, dob, dod) VALUES ('{$_POST['name']}','{$_POST['add1']}','{$_POST['add2']}','{$_POST['city']}','{$_POST['state']}','{$_POST['zip']}','{$_POST['email']}','{$_POST['decname']}','{$_POST['dob']}','{$_POST['dod']}')"
you can't call assosicative arrays inside double quotes like this!
you have to either srrounde it with braces (like what I did) or close the quote and . then reopen quotes like this:
PHP Code:

$sql "INSERT INTO table VALUES ('".$_POST['name']."')"
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #9 (permalink)  
Old 04-29-04, 09:29 AM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
that worked almost completely fabulously, thank you.

but now it says:

Notice: Undefined index: decname in C:\Program Files\Apache Group\Apache2\htdocs\sel1.php on line 31


which is that same line.
Reply With Quote
  #10 (permalink)  
Old 04-29-04, 09:30 AM
sita12691 sita12691 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
nevermind, it was a spelling error. I hate the little mistakes that you can never find until your head's about ready to explode.

:]

thanks again, everyone!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP not working in IIS5 on WinXP Pro cistate ASP 5 06-18-04 02:31 PM
HTTP_REFERER not working Kaikki ASP 6 02-22-04 02:38 PM
calendar working until months changed bitesize JavaScript 1 01-13-04 01:50 PM
Line breaks not working mdhall PHP 6 11-28-03 12:12 PM
If/else statement working...but not working mdhall PHP 13 10-16-03 08:47 AM


All times are GMT -5. The time now is 10:30 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.