473,789 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with $_POST

2 New Member
I've just started messing around with PHP and believe it or not its extremely frustrating haha. Anyway, I wanted to make a simple input form that would display the info after submitting it...

The script is a simple html script, which calls a php script passing
it the variables which it got by the forms:

**************H TML doc. named "insert.htm"*** *************** ******

<html>
<head>
<title>HTML Form</title>
</head>
<body>
<form ACTION="script1 .php" METHOD=POST>
First Name<input TYPE=TEXT NAME="FirstName " SIZE=20><br>
Last Name <input TYPE=TEXT NAME="LastName" SIZE=20><br>
E-mail Address <input TYPE=TEXT NAME="Email" SIZE=60><br>
Comments <textarea NAME="Comments" ROWS=5 COLS=40></textarea><br>
<input TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!" >
</form>

</body>
</html>



*************** ************PHP script named "script1.php"** *************** *****

<HTML>
<HEAD>
<TITLE>Form Results</title>
<BODY>

<?
$FirstName = $_POST["FirstName"];
$LastName = $_POST["LastName"];
$Email = $_POST["Email"];
$Comments = $_POST["Comments"];
?>


<?php
/* This page receives and handles the data generated by "insert.htm l".
*/
print "Your first name is $_POST["FirstName"].<BR>\n";
[color=blue]
print "Your last name is $_POST["LastName"].<BR>\n";
[color=blue]
print "Your E-mail is $_POST["Email"].<BR>\n";
[color=blue]
print "This is what you had to say:<BR>\n$_POS T["Comments"]<BR>\n";
[color=blue]
?>



</BODY>
</HTML>




I keep getting this error :


Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/grademyc/public_html/script1.php on line 17


with line 17 being
print "Your first name is $_POST["FirstName"].<BR>\n";
[color=blue]



i'm new to all this so i'm sure i've made mistakes somewhere...
please help...thanks!
Nov 30 '06 #1
9 2020
bishwadeep
12 New Member
Try this code in your line 17
<br>I think it is because you did not concat:
print "Your first name is". $_POST["FirstName"]."<BR>\n";

If any other error occurred please write me
Nov 30 '06 #2
lovinlazio9
2 New Member
sorry about that, I figured it out last night...REALLY LATE NIGHT!...unfort unately the script isn't putting anything into the MySql database though....it just keeps putting blank entries in the table...any thoughts?

my code to connect to the database is as follows:


*************** *************** **********PHP** *************** *************** ************

<?
$DBhost = "localhost" ;
$DBuser = "grademyc_m e";
$DBpass = "********";
$DBName = "grademyc_users ";
$table = "details";
mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to database");

@mysql_select_d b("$DBName") or die("Unable to select database $DBName");

$sqlquery = "INSERT INTO $table VALUES('$Name') ";

$results = mysql_query($sq lquery);

mysql_close();

?>


*************** *************** *************** *************** *************** **********

every time i try to update the database through my form is just creates a blank entry which is really annoying...i can obviously update the database via phpMyadmin, but that doesn't help me.....Thanks!
Danny
Nov 30 '06 #3
scriptee
17 New Member
sorry about that, I figured it out last night...REALLY LATE NIGHT!...unfort unately the script isn't putting anything into the MySql database though....it just keeps putting blank entries in the table...any thoughts?

my code to connect to the database is as follows:


*************** *************** **********PHP** *************** *************** ************

<?
$DBhost = "localhost" ;
$DBuser = "grademyc_m e";
$DBpass = "********";
$DBName = "grademyc_users ";
$table = "details";
mysql_connect($ DBhost,$DBuser, $DBpass) or die("Unable to connect to database");

@mysql_select_d b("$DBName") or die("Unable to select database $DBName");

$sqlquery = "INSERT INTO $table VALUES('$Name') ";

$results = mysql_query($sq lquery);

mysql_close();

?>


*************** *************** *************** *************** *************** **********

every time i try to update the database through my form is just creates a blank entry which is really annoying...i can obviously update the database via phpMyadmin, but that doesn't help me.....Thanks!
Danny
Hi ..
Try using the Insert statement with the table column name like ..

[PHP]$sqlquery = "INSERT INTO $table ('column_name_1 ','column_name_ 2', ..etc)VALUES('$ value_1, $value_2', ..etc)";[/PHP]

Hope this will work ...good luck !
Nov 30 '06 #4
chesko
1 New Member
Hello I think tha you'll better use an echo and to use simple cotes for your variable from POST :

Expand|Select|Wrap|Line Numbers
  1. print "Your first name is $_POST["FirstName"].<BR>\n";
  2. [color=blue]  
  3.  
becomes
Expand|Select|Wrap|Line Numbers
  1. echo "Your first name is $_POST['FirstName'].<BR>\n";
  2.  
or

Expand|Select|Wrap|Line Numbers
  1. echo 'Your first name is '.$_POST['FirstName'].'<BR>\n';
bye

Chesko
Nov 30 '06 #5
ronverdonk
4,258 Recognized Expert Specialist
lovinlazio9: please read the Posting Guidelines at the top of this forum before you post anything else in this forum!

Especially the part about enclosing posted code within php, code or html tags!

Ronald :cool:
Nov 30 '06 #6
moishy
104 New Member
What was the point of doing this:

$FirstName = $_POST['FirstName'];

If you're anyways gonna call the $_POST

print $_POST['FirstName'];

And not

print $FirstName;
Dec 1 '06 #7
TheMadMidget
98 New Member
To continue on from moishy's thought, (onto my own thought)
Sometimes when I used $_POST['name'] and then again later, it would show up blank. I was like it was erasing it. This was not consistent though, which really threw me for a spin, but it has only happened to me personally with IE 7.newest out.
Dec 1 '06 #8
kd8con
4 New Member
I think I would agree about the variable use rather than using POST. I always save the POSTed data to a variable as I know this will stick and it is easier to type as well.

I also think the echo is better than the print - but I don't have a clue why - I think it is just a personal preference.

Steve
Dec 2 '06 #9
ronverdonk
4,258 Recognized Expert Specialist
What was the point of doing this:

$FirstName = $_POST['FirstName'];

If you're anyways gonna call the $_POST

print $_POST['FirstName'];

And not

print $FirstName;
I hope you don't really use the $_POST in that way, moishy! You must have an endless trust in your fellow human beings. Ever heard of cross-site scripting?
You should always sanitize your outside data, especially the $_GET and $_POST arrays. They are the main source for XSS attacks.

Ronald :cool:
Dec 2 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2323
by: Tiernan | last post by:
Hey everybody. I'm verry new to PHP and MYSQL and have been working on a form that when it is submitted stores the information into a mysql database. The main problem is that i'm trying to finish up my script for almost a week now and I still cant get it right. here is the code <?php include ("ES_includes/appconst.inc.php") ;
5
2359
by: Jerry Polyak | last post by:
Can someone give me a pointer, please. I am getting the following errors: Notice: Undefined index: sender_name in c:\program files\apache group\apache\htdocs\allinone_form.php on line 12 Notice: Undefined index: sender_email in c:\program files\apache group\apache\htdocs\allinone_form.php on line 14
9
2504
by: Don Seckler | last post by:
I am trying to set up a PHP web page so I can enter data into a database. I created a form: <form action="admin_news_insert_processor.php" method="post" name="frm_Insert_News" id="frm_Insert_News">
1
2680
by: JaNE | last post by:
Hello, I have made my cms... and is working, but have some, let me say "bugs"... And I don't know all reasons, please allow me slightly longer and most probably confusing post (that "confusing" is mainly becaose of my bad english, and that bad english is also reason why am I learning php that slow...). As first, what is problem: some users after succsesfull registration and login can not see "memeber_menu" and can not activly participate...
2
1602
by: Jeffrey D Moncrieff | last post by:
I am trying to create a data base for colleting date for my research project. I have run in to a couple of problems and I need it fast ASAP I need it to be able to add data and edit them and view the data form a public site. I have not use mysql and php since 2003 I have created the date base with 2 tables 1 for a Jump Menu and on for the content. The contents is in a table called PR and I as soon as I enter the data and hit submit the web...
6
1979
by: admin | last post by:
Hi, I have a mysql box that has a private network ip. The old developer was running our web server on this machine but the company since retired the box and it is in a closet, still running, but sad and alone, aliased as oldserver.mycompany.com. Now I am finding out that I need to use some of the funcitonality in the scripts that are on the old box.
11
1794
by: shror | last post by:
Hi every body, Please I need your help solving my php mail() function problem that the code is appearing in the view source and I dont know whats the problem where I am using another page tto test the php and its executed very nice The page have php code viewed : http://beachtoursegypt.com/booking-form.htm where after submitting the form the data are sent to the confirmation age where the php script lies there and its not executed
8
28256
by: punitshrivastava | last post by:
Hi to All. I am Punit .I am back with new question .Please help me. I want to create one enquiry form in php.for this I code it: form code: <form name="enquiry" method="post" action="enquiry.php">
2
1764
by: Baldaris | last post by:
Hi I am using Xampp , Php 5.2.6 and phpedit for wiriting code. i am trying to add the content's from user form and then add then into the data base. It check's if submit is clicked or not , Then if any of the field's are empty -- It should show an error , it shold check if user name is there in the data base or not...if yes show error message otherwise insert into database.
1
3209
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the code for attachment, I am not able to send anything. I get blank email. Can you please help me on this? Here is the html form:
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7525
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5415
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.