473,500 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP not parsing forms

Here is the code that I used to test my server, very simple, right?
But when I click on submit, nothing.. I've also tried similar things
with php and mysql and all it did was create empty fields in the table.
What am I doing wrong? Please help, Ultimatly I want to parse a form
into a mysql database, but if I can't get the php engine to pass data
from the forms correctly then it's no use to go any further.

<?php

if ($submit == "click"){
echo "Hello, $UserName";
}
else{
echo '
<html><body>

<form method="post" action="form.php">

Enter Your Name
<input type="text" name="UserName"></input><br>

<input type="submit" name="submit" value="click"></input>

</form>

</body></html>
';
}

?>

Jul 17 '05 #1
3 1985
wi******@gmail.com wrote:
Here is the code that I used to test my server, very simple, right?
But when I click on submit, nothing..


Your code doesn't work because register globals have been disabled. This is
easily fixed by retrieving the post data explicitly.

Add this to the top of your PHP code:

$submit = $_POST['submit'];

More info here: <http://uk.php.net/register_globals>

--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
Jul 17 '05 #2
wi******@gmail.com wrote:
Here is the code that I used to test my server, very simple, right?
But when I click on submit, nothing..

<html><body>
<form method="post" action="form.php">
Enter Your Name
<input type="text" name="UserName"></input><br>
<input type="submit" name="submit" value="click"></input>
</form>

<?php
if ($submit == "click"){
echo "Hello, $UserName";
}
?>
</body></html>


Since 4.2.0 register_globals [1] is off by default due to security
reasons [2]. One should use super globals (introduced in 4.1.0) instead
to get to user supplied data [3]. So either fix:

-fix your code [4]:
if(isset($_POST['submit']) && $_POST['submit']=="click")
{
echo 'Hello, '.$_POST['UserName'];
}
-quick&dirty hack:
extract($_REQUEST);
in the global scope.
-enable register_globals

1: http://www.php.net/manual/en/ini.cor...gister-globals
2: http://www.php.net/manual/en/security.globals.php
3: http://www.php.net/manual/en/languag...s.superglobals
4: $_POST['UserName'] should offcourse be escaped properly (with
htmlspecialchars in this particular case).
Jul 17 '05 #3
NC
wispt...@gmail.com wrote:

Here is the code that I used to test my server, very simple, right?
But when I click on submit, nothing.. .... if ($submit == "click"){
echo "Hello, $UserName";
}
else{
echo '
<html><body>
<form method="post" action="form.php">
Enter Your Name
<input type="text" name="UserName"></input><br>
<input type="submit" name="submit" value="click"></input>
</form>
</body></html>
';
}


You probably have register_globals turned off (and you should).
Put this in the beginning of your script:

$UserName = $_POST['UserName'];
$click = $_POST['click'];

Cheers,
NC

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2571
by: YoBro | last post by:
Hi I have used some of this code from the PHP manual, but I am bloody hopeless with regular expressions. Was hoping somebody could offer a hand. The output of this will put the name of a form...
8
9424
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
16
2849
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
2
1995
by: please-answer-here | last post by:
Scenario: I'm having an asp page with a form with an action pointing to itself. The reason for that, it that the asp page depending on changes in any of two select fields with data from 2...
11
2074
by: Sven Neuberg | last post by:
Hi, I have been handed the task of updating and maintaining a web application, written in ASP and Javascript, that takes complex user inputs in HTML form and submits them to server-side ASP...
3
2447
by: djdave | last post by:
My problem is that i need an algorithm parse parse HTML. For an HTML page, my script has to parse all tags to get all forms values, even if there is frame, iframe, ... How can i do such a script ?...
3
3267
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a...
7
3773
by: John Nagle | last post by:
Is there something available that will parse the "netloc" field as returned by URLparse, including all the hard cases? The "netloc" field can potentially contain a port number and a numeric IP...
1
3371
by: Rick Owen | last post by:
Greetings, I have a form that, when submitted, calls a plsql procedure. The form has a number of fields (text, hidden, select, radio) but the particular field that is giving me problems is a...
1
2185
nine72
by: nine72 | last post by:
Ok, I am at a complete loss on this and have finally come to the XML Parsing Gods (and perhaps a PHP minor deity) for guidance… I will try my best to describe what I have going on… 1) I have 15...
0
7136
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
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...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.