Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | Help needed with web forms:

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > Internet Discussion
Register FAQ Community Calendar

Help needed with web forms:
Reply
 
Thread Tools
Old 19-08-2005, 22:41   #1
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Help needed with web forms:

Hi Guys,

I need a little help with creating a web form.

I'm starting from scratch so please excuse me if I sound like a bit of a

Using DreamWeaver, how do I create a form? It needs to have 2 fields that the user can enter data into and two buttons, one button will be used to carry out an SQL search on a database and the other will be used to reset the form fields.

If anybody could give me a little help to get started I would really appreciate it.
Raistlin is offline   Reply With Quote
Advertisement
Old 19-08-2005, 23:13   #2
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Re: Help needed with web forms:

<form action="processing-file.php" method="get">
<input type="text" name="variable-field" />
<input type="hidden" name="stuff-you-want-to-carry-over" value="variable-value" />
<input type="submit" value="Go" />
</form>

It's not really that hard...to get you started:
http://www.w3schools.com/html/html_forms.asp
BTW - I hear you're creating something for CF - I can clean up everything and check the code...
Richard M is offline   Reply With Quote
Old 19-08-2005, 23:18   #3
philip.j.fry
Inactive
 
philip.j.fry's Avatar
 
Join Date: Jul 2003
Posts: 1,395
philip.j.fry has reached the bronze age
philip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze age
Re: Help needed with web forms:

The w3c schools are always good: http://www.w3schools.com/html/html_forms.asp

I'm not sure how you do it graphically in DW but if you go to code view the html should be something like:

Code:
<form name="my_form" action="form_submit.php" method="GET">
<input type="text" name="text_one"><br>
<input type="text" name="text_two"><br>
<input type="submit" value="Submit"><br>
<input type="reset" value="Clear">
</form>
Hope that gives you enough to be going on with, I'm off to bed

Edit: At least Rich and I are in agreement and not confusing you
philip.j.fry is offline   Reply With Quote
Old 20-08-2005, 00:20   #4
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Ok, I've got the form part working, it passes two variables to a .php page.

The .php page queries a database and returns some values, based upon what was input in the form.

I then need to take some of the values from the record and some of the values from the form and perform an UPDATE.

So, from the form:

$usrInputName
$usrInputSearch

The SELECT query (which works) is:

PHP Code:
$result = mysql_query("SELECT * FROM tblMyTable WHERE requiredfield = '$usrInputSearch'",$link); 
I can then "echo" all of the fields from the one returned record so that they output in the browser.

What I now need to do is take the usrInputName value and append it to the end of what is currently in one of the fields returned by the SELECT statement.

So, I'm doing this:

PHP Code:
mysql_query("UPDATE tblMyTable SET TheFieldToAmend = $row[TheFieldToAmend] . '<BR>' . $usrInputName WHERE id = $row[id] LIMIT 1"); 
So:

If TheFieldToAmend = This
And $usrInputName = Raistlin

I want the value of TheFieldToAmend for the selected record (identified by $row[id] returned by the SELECT query) to be:

This<BR>Raistlin
Raistlin is offline   Reply With Quote
Old 20-08-2005, 00:30   #5
Gareth
cf.mega poster
 
Gareth's Avatar
 
Join Date: Dec 2003
Age: 51
Posts: 7,101
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Re: Help needed with web forms:

Why would you want to include that inside a sql statement? Why not retrieve the values and then manipulate or concatonate them within your php code afterwards?
Gareth is offline   Reply With Quote
Old 20-08-2005, 00:33   #6
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Quote:
Originally Posted by Richard M
BTW - I hear you're creating something for CF - I can clean up everything and check the code...
Sorry, forgot to say....Thanks

I'll certainly take you up on that, I'm trying to do as much of the fiddly stuff as possible - the theory being that once the hard work's done someone wonderful (like you ) can help me just get it a little bit tidy
__________________

Quote:
Originally Posted by Gareth
Why would you want to include that inside a sql statement? Why not retrieve the values and then manipulate or concatonate them within your php code afterwards?
The values have already been retrieved, I now want to concatenate them (love that word ) and amend the table in the database - wasn't aware that I could do that without a SQL statement
__________________

Quote:
Originally Posted by philip.j.fry
Edit: At least Rich and I are in agreement and not confusing you


Nah, I think I'm confusing myself Thanks
Raistlin is offline   Reply With Quote
Old 20-08-2005, 00:34   #7
Gareth
cf.mega poster
 
Gareth's Avatar
 
Join Date: Dec 2003
Age: 51
Posts: 7,101
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Re: Help needed with web forms:

Oh, so you want the field value to contain the html tags that you're using...? Am I understanding this correctly? I've had a few tonight
Gareth is offline   Reply With Quote
Old 20-08-2005, 00:40   #8
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Yep:

Say (for example) that the field value was originally:

THIS

I want it to be:

THIS<BR>WORD

So that when it is displayed on a web page it looks like:

THIS
WORD

Does that make sense, I haven't slept much in the last 72 hours so I'm a bit muddled myself
Raistlin is offline   Reply With Quote
Old 20-08-2005, 03:49   #9
Richard M
Inactive
 
Join Date: Jun 2003
Location: Los Angeles, CA
Age: 47
Posts: 6,343
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Richard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze arrayRichard M has a bronze array
Re: Help needed with web forms:

PHP Code:
$result = mysql_query("SELECT * FROM tblMyTable WHERE requiredfield = '$usrInputSearch'",$link); 
Very insecure code there...

I could (if I wanted to) change that code to this:

PHP Code:
$result = mysql_query("SELECT * FROM tblMyTable WHERE requiredfield = '$usrInputSearch'; UPDATE usertable SET pwd='0wned', admin='I-am-admin', trusted=100",$link); 
That might have given me full access to the database...

And all I would have had to do is thus:

www.yoursite.com/script.php?usrInputSearch=blahblah';%20UPDATE %20usertable%20SET%20pwd='0wned',%20admin='I-am-admin',%20trusted=1;

Scary no?
Richard M is offline   Reply With Quote
Old 20-08-2005, 12:03   #10
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Quote:
Originally Posted by Richard M
PHP Code:
$result = mysql_query("SELECT * FROM tblMyTable WHERE requiredfield = '$usrInputSearch'",$link); 
Very insecure code there...

I could (if I wanted to) change that code to this:

PHP Code:
$result = mysql_query("SELECT * FROM tblMyTable WHERE requiredfield = '$usrInputSearch'; UPDATE usertable SET pwd='0wned', admin='I-am-admin', trusted=100",$link); 
That might have given me full access to the database...

And all I would have had to do is thus:

www.yoursite.com/script.php?usrInputSearch=blahblah';%20UPDATE %20usertable%20SET%20pwd='0wned',%20admin='I-am-admin',%20trusted=1;

Scary no?
Yep, very scary

So, how do I get round that?

This is my first attempt at doing anything with PHP
Raistlin is offline   Reply With Quote
Old 20-08-2005, 20:43   #11
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Anybody?
Raistlin is offline   Reply With Quote
Old 21-08-2005, 00:35   #12
philip.j.fry
Inactive
 
philip.j.fry's Avatar
 
Join Date: Jul 2003
Posts: 1,395
philip.j.fry has reached the bronze age
philip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze age
Re: Help needed with web forms:

Quote:
Originally Posted by Raistlin
Anybody?
Connect to the db with a user that only has SELECT privilidges and use that connection for your query. Alternatively you can parse the input to make sure there is no nasty stuff. Or do both
philip.j.fry is offline   Reply With Quote
Old 23-08-2005, 21:54   #13
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Ok, so I connect to the database with an account that only has SELECT privileges - how do I then do the update that I want to do on the table?

I'm assuming that I would then need to connect using an account that has UPDATE privileges but then I'm running the same risk surely?

Not sure how I'd go about "parsing the input" either, I'm really new to all this PHP stuff.

Richard would appreciate any more comments you have on this security issue, unless I can get this resolved I'm on to a real no starter here
Raistlin is offline   Reply With Quote
Old 23-08-2005, 22:00   #14
Paul K
Inactive
 
Paul K's Avatar
 
Join Date: Jun 2003
Location: Essex innit
Age: 52
Services: Sky HD + 16Mb ADSL BT Telephone
Posts: 15,735
Paul K is seeing silvered starsPaul K is seeing silvered starsPaul K is seeing silvered starsPaul K is seeing silvered starsPaul K is seeing silvered starsPaul K is seeing silvered starsPaul K is seeing silvered stars
Paul K is seeing silvered starsPaul K is seeing silvered starsPaul K is seeing silvered stars
Re: Help needed with web forms:

May need to PM him for advice, he was last active 30 mins ago, I'm sure he won't mind since he is interested in what you are trying to create
Paul K is offline   Reply With Quote
Old 23-08-2005, 22:01   #15
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Help needed with web forms:

Quote:
Originally Posted by Paul
May need to PM him for advice, he was last active 30 mins ago, I'm sure he won't mind since he is interested in what you are trying to create
May do if he doesn't see this, if he's not been active for a while he won't see the PM either

Thanks though
Raistlin is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:26.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum