|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
A PHP that adds user input into SQL
Well, hopefully you folks here can help me out, as I am just learning my way through PHP.
My current site is a directory type site, where users can submit info using a reular HTML form which emails the info to me. I then take those emails and update the code by hand then uplaod to the server. Well, spare time is getting shorter each day, so I want to automate this process using SQL. I want the users to be able to submit the info, which will automatically be placed into SQL, then have certain info called and displayed throughout the site. I found some code for a PHP form, but I get a parse error, Can somone here take a look to see if I'm even close to what I want to do? PHP Code:
The parse error seems to be with the POST statement, but I have no idea what needs to be fixed. Please be gentle as I know literally nothing about PHP. ![]() Also, is there a way to do this without having to have the username and password in the code itself? Thanks in advance. EDIT: there is a \ right after the = sign in the POST statement, but it doesn't show in the code above. Could that be what it is? Maybe the browser can't read it the way I have it? |
|
#2
|
||||
|
||||
|
Here's your error... in the write_form() function:
print "<form method="POST\">\n"; you need to put a backslash before the one quote, in order to tell PHP to escape the quote... So the line should read: print "<form method=\"POST\">\n"; this way, when the line is parsed, the HTML will read as expected: <form method="POST"> For future reference, it helps to give us the exact error, and perhaps the block of code that you think the error is coming from... saves people from having to read every single line... Best of luck learning PHP! |
|
#3
|
|||
|
|||
|
The backslash is there. When I pasted the code in the above post, it didn't show.
The error I'm getting is this: Parse error: parse error in /www/m/musicians/htdocs/test.php on line 157 Line 157 is the print "<form method=\"POST\">\n"; line. Is there another way to write that line? |
|
#4
|
||||
|
||||
|
Now that I look at it, is there a reason that block of code is interpretted by php?
With PHP you can always escape PHP and write normal HTML... Example: PHP Code:
*edit* It didn't show up as I expected on my screen, but notice the ?> and <? surrounding the HTML... that's important... =) *edit* This is cheating, I know... honestly, this line print "<form method=\"POST\">\n"; should work... |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > A PHP that adds user input into SQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|