Web Design Using Forms

Discussion in 'Software' started by punkandrock, Mar 8, 2008.

  1. punkandrock

    punkandrock Private E-2

    Alright I will attempt to explain my needs. Someone will go on to this website and fill out a form giving there name, address, etc. They then hit submit. It takes them to the next page on that next page it takes there data and fills it in to an already made web page. Telling them welcome, "Name", your address is "there address", etc. How do I do this, creating variables that will be updated by the user on the page before?
     
  2. matrixblue

    matrixblue Private E-2

    You need a scripting language like PHP. You can set the form to create variables and display those form variables on the next page.

    I'm a little rusty in the scripting department these days but if you use PHP there are hundreds of sites that can guide you in the right direction (This website uses PHP).

    Keep in mind that scripting languages such as PHP, ASP and Coldfusion are Server-side scripting and as such your web server must have support for which ever language you use installed.
     
  3. PC-XT

    PC-XT Master Sergeant

    If you could format the data so it is acceptable as a url query, there are ways of extracting variables from location.search using JavaScript. I wrote a routine that returns an object a bit like PHP's $_GET[]. For instance, if the first page has three fields: name, address, phone. The form would use method=get and make a call to the next page (for example, nextpage.htm) like this: nextpage.htm?name=Chris&address=1121+Main+Street&phone=555-555-5555
    nextpage.htm would include a script to retrieve this info like this:
    Q=location.search.substring(1,location.search.length);//get part after ? into temp var Q
    Q=Q.split("&");//split into array of fields
    field=new Array();
    //next line assigns each field name to the unescaped value (including + to space)
    for(i in Q){t=Q.split("=");field[t[0]]=unescape(t[1]).split("+").join(" ");}
    //You could use replace instead of split and join, but I found split and join seem to work better in these circumstances for some reason.
    To use the field values after this script, simply use the script code field["field name"]
    field["name"] would be "Chris", field["address"] would be 1121 Main Street, field["phone"] would be 555-555-5555
    My own script is more complicated, for use with multiple selections, etc., but this one will work in many cases.
    Disadvantages of this are that not all browsers use scripts, and browsers have a limit to the length of the url (some as small as 255 characters, including the full path and query.)
    I usually use PHP to do this stuff, as it is usually better, but this script needs no server. You can use it while working offline (from browser cache or files on disk). PHP requires connection to the server.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds