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:
**************HTML 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.html".
*/
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$_POST["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!
9 1999 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
sorry about that, I figured it out last night...REALLY LATE NIGHT!...unfortunately 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_me";
$DBpass = "********";
$DBName = "grademyc_users";
$table = "details";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$Name')";
$results = mysql_query($sqlquery);
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
sorry about that, I figured it out last night...REALLY LATE NIGHT!...unfortunately 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_me";
$DBpass = "********";
$DBName = "grademyc_users";
$table = "details";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$sqlquery = "INSERT INTO $table VALUES('$Name')";
$results = mysql_query($sqlquery);
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 !
Hello I think tha you'll better use an echo and to use simple cotes for your variable from POST : - print "Your first name is $_POST["FirstName"].<BR>\n";
-
[color=blue]
-
becomes -
echo "Your first name is $_POST['FirstName'].<BR>\n";
-
or - echo 'Your first name is '.$_POST['FirstName'].'<BR>\n';
bye
Chesko
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:
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;
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.
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
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:
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
...
|
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"...
|
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...
|
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...
|
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...
|
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...
|
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" ...
|
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 ,...
|
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...
|
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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |