HI,
I installed php4 for apached and restart apache afterward. but my little
php script generated error followint error:
PHP Notice: Undefined index: myname in
/usr/local/www/data-dist/www.authtec.com/php-test.php on line 2
I was trying to run the following php script in apache:
<?php
if($_POST["myname"]) {
print "Hello, ".$_POST["myname"]."<p>\n"
.nl2br($_POST["textbox"]);
} else {
?>
<form method="post" action="php-test.php">
<input type=input type=text name=myname>
<textarea cols=20 rows=4 wrap=virtual name=textbox></textarea>
<input type=submit value="Submit">
</form>
<?php
}
?>
What could be wrong with my configuration? and how can I fix it?
Thanks
Sam 3 2993
sam wrote:
<snip> <?php if($_POST["myname"]) { print "Hello, ".$_POST["myname"]."<p>\n" .nl2br($_POST["textbox"]); } else {
<snip>
You are getting a notice, not an error. Do this instead:
if(isset($_POST["myname"]))
and your notice will be gone.
Sam,
You should _always_ make sure a key exists in an array before using it.
<?php
if (array_key_exists('myname', $_POST) ) {
echo "<p>Hello, ", $_POST['myname'], "</p>";
}
?>
I also would suggest a function which looks in both $_POST and $_GET for a
parameter, unescaping it if necessary.
HTH,
La'ie Techie
please help me with this:
i have the same problem and when i tried to do same thing as u stated wherein adding an "isset" function, the form will not appear when i run it.
i recieved this warning: Notice: Undefined index: login in D:\WebDeveloped\login.php
code is here:
if (!$logged['username'])
{
if (!$_POST['login'])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Login\">
</td></tr><tr>
<td align=\"center\">
<a href=\"register.php\">Register Here</a>
</td></tr></table></form></center>");
}
if ($_POST['login']) {
// the form has been submitted. We continue...
$username=$_POST['username'];
$password = md5($_POST['password']);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Incorrect username or password!";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
setcookie("id", $user['id'],time()+(60*60*24*5), "/", "");
setcookie("pass", $user['password'],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://test/editprofile.php\"/>Thank You! You will be redirected");
}
}
}
else
{
// we now display the user controls.
echo ("<center>Welcome <b>$logged[username]</b><br /></center>
- <a href=\"editprofile.php\">Edit Profile</a><br />
- <a href=\"members.php\">Member List</a><br />
- <a href=\"logout.php\">Logout</a>");
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David Schwartz |
last post by:
We are having quite a time since moving a large database to a new
server (actually built new server, renamed as old to make seamless for
users, etc.)
Import 104 million row database (5 column)...
|
by: Rafal 'Raf256' Maj |
last post by:
Hi,
is there a commend to undefine all macros #define inside a file?
in example:
#define FOR(x) for (..............)
#define MyMacro1(x,y) ...........
// ... code ...
|
by: Sean C. |
last post by:
Helpful folks,
Most of my previous experience with DB2 was on s390 mainframe systems
and the optimizer on this platform always seemed very predictable and
consistent. Since moving to a WinNT/UDB...
|
by: Waldo Nell |
last post by:
Hi,
I have a *huge* problem. I have a table with indexes on but the moment
I have an OR in my SELECT query it seems to not use the appropriate
index.
oasis=> \d purchases
Table...
|
by: Alden Pierre |
last post by:
Hello,
I'm trying to create my own user define container, but I'm having a
little hard time figuring out why is my class considered undefined by my
compiler. Here is the following code.
//...
|
by: greenflame |
last post by:
hello all,
I have installed apache and php following the instructions on this link
which was very helpful:
http://www.tanguay.at/installPhp5.php5
problem:
OS: Windows XP
|
by: Rocky86 |
last post by:
hi people basically I am having a problem with the followinng code:
$names=sizeof($temp);
$report="total=$names&";
foreach($temp as $list)
$report.="name".$names--."=".$list."&";
echo...
|
by: Pietro Cerutti |
last post by:
Hi Group,
is there a mean to undefine a function, in a similar way as you can
undefine macros?
For example, let's say that I need a few declarations from stdio.h but
want to define my own...
|
by: JJM0926 |
last post by:
I've got a contact form with a submit button where users have to enter
their support information. Some fields are required some are not.
When I test out the form if I leave everything blank I get...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |