There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows vista windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
PHP / html coding problem


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Brooook's Avatar
Senior Member with 157 posts.
 
Join Date: Oct 2002
Location: Nelson, New Zealand
04-Oct-2003, 01:20 AM #1
PHP / html coding problem
or is it a PHP config problem?

I am teaching myself PHP / MySQL and getting to the coding stage and written some complex code that doesn't work. So figured it wasn't getting the input and went right back to the basics.

Here is the coding for a simple HTML input to a simple PHP file. I put in the boolean functions so I could see if, infact, the data was getting input.

No matter what I entered, or if I did not enter anything, the functions would return as NOT isset, and display 1 as IS empty. So I think the problem is I am not getting the data from HTML to the PHP file.

Am I missing something simple in the code? Or have I not configured the php.ini correct?

I have noone to ask and thought the code was correct (copied from learning text!). HELP

//simplehtml.html

<HTML>
<HEAD>
<TITLE><Simple HTML / PHP form> </TITLE>
</HEAD>
<BODY>
<h1>Simple HTML / PHP form</h1>
<form action="oknow.php" method="POST">
Name: <input type="text" name="username"><br>
Email: <input type="text" name="email"><br>
<input type="submit" name="submit" value="Submit me!">
</form>
</BODY>
</HTML>

//---------------------------------------------------------------

//oknow.php

<HTML>
<HEAD>
<TITLE><OK Lets see what happens> </TITLE>
</HEAD>
<BODY>
<h1>OK Lets see what happens</h1>
<?php
echo "<p> <br>";
echo isset($username);
echo "isset username <br>";
echo isset($email);
echo "isset email <br>";
echo empty($username);
echo "empty username <br>";
echo empty($email);
echo "empty email ";
?>
</body>
</html>
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
04-Oct-2003, 01:28 AM #2
First, $email should be
$_POST['email']
etc. You probably also want to use some IF statements...or the output is going to look strange.
Brooook's Avatar
Senior Member with 157 posts.
 
Join Date: Oct 2002
Location: Nelson, New Zealand
04-Oct-2003, 01:51 AM #3
So simple!!!!
I have been pulling my hair out all day over this!!!

Don't worry, it was just test code and I knew what it meant. After correcting the PHP file it came back TRUE for isset and FALSE for empty so I knew it was the answer. I then corrected the more complex code (searching for books, connecting to a database , etc) and WOW it works. I was so worried it wasn't connecting to MySQL and finally narrowed it down to it not inputing my search terms etc.

THANK YOU. I did see $_POST in my PHP manual but it is not written in any of the test codes that I was learning (and typing out manually) so didn't quite know what to make of it. Now it will always be included.

THANK YOU AGAIN
deuce868's Avatar
Senior Member with 638 posts.
 
Join Date: Nov 2000
Location: MI
04-Oct-2003, 11:40 AM #4
it looks like you are using global variables set to on in your php.ini. This is a very insecure method of running the server. The reason the $_POST is in there is to specify you want the variables that was POSTED not one passed in the url and such.

I would HIGHLY recommend that you spend some time looking into what global variables are and why they are bad.
__________________
www.ricksweb.info
www.2webheads.com
Quote:
Techies just think a little differently...at least that's what they keep telling me.
Brooook's Avatar
Senior Member with 157 posts.
 
Join Date: Oct 2002
Location: Nelson, New Zealand
04-Oct-2003, 06:51 PM #5
I already thought of that
and had checked my php.ini file and the register_globals was set to Off. It has always been that way - is that why it DIDN'T work until I corrected the code to $_POST? I had thought of changing it to On to see if this corrected the problem but I didn't want to for the reasons in your post and the $_POST worked so I didn't touch it.

The best thing I did was ask for TSG help before I changed things in php.ini. It took weeks (without help) to get the appropriate settings in the different config files for PHP, MySQL & Apache to communicate so I was loathe to change anything!
brendandonhu's Avatar
Distinguished Member with 15,988 posts.
 
Join Date: Jul 2002
Location: Ann Arbor, MI
Experience: Advanced
04-Oct-2003, 07:07 PM #6
Yes, changing register_globals to On would have fixed the problem, but things are better with no global variables.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:36 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.