potential problems with $PHP_SELF?
Moderator: General Moderators
-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
potential problems with $PHP_SELF?
i have a VERY simple form that takes an email address and adds it to a mysql database. the form works great in firefox but i've been having problems with it in IE. strangely enough, i have other forms that work fine in both browsers. the only difference is that the broken form is using $PHP_self as the action. could this cause a problem? could there be browser options that aren't allowing this to work correctly?
when an email is input the user should simply see "email added" below the input widow (and the window will clear). right now the window just clears but nothing is displayed.
let me know if you need to see code or have any other questions.
thanks
lee
when an email is input the user should simply see "email added" below the input widow (and the window will clear). right now the window just clears but nothing is displayed.
let me know if you need to see code or have any other questions.
thanks
lee
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
i know you probably didn't want all this but this might clear up any other questions
thanks for your help with this.
lee
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>
<body bgcolor="#000000" background="../images/bg.jpg" vlink="#FF00FF">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="signupForm">
<font face="Verdana" size="2"><input type="text" name="new_email" align="TOP" size="15">
<input type="submit" value="Submit" name="submit" align="MIDDLE" style="font-family: Verdana">
</form>
<?php
include 'functions.php';
//******************************************************
// Check for completed field.
//******************************************************
if (isset($submit)) {
if(!$new_email) {
die("<br>Enter an email address first!");
}
else{
$status = ValidateEmail($new_email);
switch($status){
case 0:
break;
case 1:
die("<br>Invalid address, try again.");
break;
case 2:
die("<br>Invalid address, try again.");
break;
}
connect_and_select_db();
$result = mysql_query("SELECT email FROM mailingList");
$num_rows = mysql_num_rows($result);
for($i=0; $i<$num_rows; $i++){
$email = mysql_result($result,$i,"email");
if($email == $new_email){
die("<br>You're already on the list.");
}
elseif($email != $new_email and $i+1==$num_rows){
mysql_query("INSERT INTO `mailingList` ( `primary ` , `first` , `last` , `email` ) VALUES ('', '', '', '$new_email');");
echo "<br>Address added successfully.";
echo "<br>", $num_rows, " total entries";
}
}
}
}
?>
</body>
</html>
thanks for your help with this.
lee
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>
<body bgcolor="#000000" background="../images/bg.jpg" vlink="#FF00FF">
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" name="signupForm">
<font face="Verdana" size="2"><input type="text" name="new_email" align="TOP" size="15">
<input type="submit" value="Submit" name="submit" align="MIDDLE" style="font-family: Verdana">
</form>
<?php
include 'functions.php';
//******************************************************
// Check for completed field.
//******************************************************
if (isset($submit)) {
if(!$new_email) {
die("<br>Enter an email address first!");
}
else{
$status = ValidateEmail($new_email);
switch($status){
case 0:
break;
case 1:
die("<br>Invalid address, try again.");
break;
case 2:
die("<br>Invalid address, try again.");
break;
}
connect_and_select_db();
$result = mysql_query("SELECT email FROM mailingList");
$num_rows = mysql_num_rows($result);
for($i=0; $i<$num_rows; $i++){
$email = mysql_result($result,$i,"email");
if($email == $new_email){
die("<br>You're already on the list.");
}
elseif($email != $new_email and $i+1==$num_rows){
mysql_query("INSERT INTO `mailingList` ( `primary ` , `first` , `last` , `email` ) VALUES ('', '', '', '$new_email');");
echo "<br>Address added successfully.";
echo "<br>", $num_rows, " total entries";
}
}
}
}
?>
</body>
</html>
-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
sorry it wouldn't let me edit the previous post. here it is again.
Code: Select all
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>
<body bgcolor="#000000" background="../images/bg.jpg" vlink="#FF00FF">
<form action="<?php echo $_SERVERї'PHP_SELF'];?>" method="post" name="signupForm">
<font face="Verdana" size="2"><input type="text" name="new_email" align="TOP" size="15">
<input type="submit" value="Submit" name="submit" align="MIDDLE" style="font-family: Verdana">
</form>
<?php
include 'functions.php';
//******************************************************
// Check for completed field.
//******************************************************
if (isset($submit)) {
if(!$new_email) {
die("<br>Enter an email address first!");
}
else{
$status = ValidateEmail($new_email);
switch($status){
case 0:
break;
case 1:
die("<br>Invalid address, try again.");
break;
case 2:
die("<br>Invalid address, try again.");
break;
}
connect_and_select_db();
$result = mysql_query("SELECT email FROM mailingList");
$num_rows = mysql_num_rows($result);
for($i=0; $i<$num_rows; $i++){
$email = mysql_result($result,$i,"email");
if($email == $new_email){
die("<br>You're already on the list.");
}
elseif($email != $new_email and $i+1==$num_rows){
mysql_query("INSERT INTO `mailingList` ( `primary ` , `first` , `last` , `email` ) VALUES ('', '', '', '$new_email');");
echo "<br>Address added successfully.";
echo "<br>", $num_rows, " total entries";
}
}
}
}
?>
</body>
</html>-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
- smpdawg
- Forum Contributor
- Posts: 292
- Joined: Thu Jan 27, 2005 3:10 pm
- Location: Houston, TX
- Contact:
You can check register_globals by running phpinfo() and looking for the entry that mentions register_globals.
If it is off, you will not be able to access post variables, etc. by name and must you the $_POST superglobal instead. BTW - This is the preferred behavior in PHP.
So instead of saying this
You would say
And this would also apply to the POST variable new_email.
If it is off, you will not be able to access post variables, etc. by name and must you the $_POST superglobal instead. BTW - This is the preferred behavior in PHP.
So instead of saying this
Code: Select all
if (isset($submit)) {Code: Select all
if (isset($_POSTї'submit'])) {-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
lscarmichael
- Forum Newbie
- Posts: 13
- Joined: Mon Mar 07, 2005 6:37 am
ok, see what you think of this.
i put an echo after each line of code (starting inside the <?php). it looks like this:
and so on......
so, when i fill in my form and hit enter i get:
what could this mean?
i put an echo after each line of code (starting inside the <?php). it looks like this:
Code: Select all
<?php
echo "<br>in php block";
include 'functions.php';
echo "<br>after include funtions";
//******************************************************
// Check for completed field.
//******************************************************
echo "<br>submit = ", $submit;
if (isset($_POSTї'submit'])) {
echo "<br>in isset";
if(!$new_email) {
echo "<br>in if";
die("<br>Enter an email address first!");
}
else{ echo "<br>in else";so, when i fill in my form and hit enter i get:
so when i hit the button something fishy is going on...it's like it's not taking the button action...in php block
after include funtions
submit =
what could this mean?