22 users online (0 members and 22 guests)  


  Results 1 to 10 of 10

Related

  1. Replies: 1
  2. Replies: 4
  3. Replies: 1
  4. Form Handling Script for 'Tell A Friend' Form    Forum: Javascript Forum
    Replies: 1
  5. Replies: 3
  1. #1
    souper's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    4

    Form Processors? Or am I looking for something else?

    Heya, this is my first post here as i'm looking to find any info regarding this question I have.
    Most form processors submit the results to your email. I'm looking for something that submits the results to a separate php or html file on the site, viewable to the public. These submissions would be placed on top of each other, not replacing each other. Kinda like a news publisher.
    For example, if I have a form with input fields such as :
    Name
    Age
    Interests

    Each field would be designated with it's own variable, such as Name = $name (or whatever). This would allow me to use these variables and implement them into the 'separate' page of the site, where ever I choose.
    Is there a script capable of such tricks?
    Last edited by souper; 11-01-2007 at 03:56 PM.

  2. #2
    MdBenner's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Posts
    12

    Re: Form Processors? Or am I looking for something else?

    Hi,

    So you want to collect information with a form and then display all the collected information in a table for instance on another page? The question would first of all be where you want to save the information? If that is not an issue yet let me know if I got your problem right and I will try to help you.

    Simon

  3. #3
    souper's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    4

    Re: Form Processors? Or am I looking for something else?

    Hey Benner,

    Thanks for the response. I actually figured out how to send and retrieve the data using a mysql database and php.

    The problem I face now is not knowing how to edit/delete the records in the database. I know there are tons of tutorials out there that will basically give the code to you and all you gonna do is edit the values and what not, but I still can't get it to work.

    All I get is a blank page when I open up the site. :/

  4. #4
    MdBenner's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Posts
    12

    Re: Form Processors? Or am I looking for something else?

    Hi,

    one thing you should always do when you are having trouble with mysql is modify the mysql_query() line as follows:

    $sql="HERE PUT YOUR QUERY";
    mysql_query($sql) or die(mysql_error());

    in case you have an error in your mysql syntax or structure it will tell you what happened or where to look for the mistake.

    for deleting an entry use the following query:

    $sql="DELETE FROM `table-name` WHERE `ID`=`5` LIMIT 1";
    mysql_query($sql);

    This would delte the entry where the column ID has the value 5 (you can use any other columname and value obviously). The limit statement esures that only one entry is deleted. Whenever possible you should use this to make sure you don't delete data you want to keep.

    for updating use this syntax:

    $sql="UPDATE `table-name` SET `column-name`='value' [,`column-name2`='value2'] LIMIT 1";
    mysql_query($sql);

    it is pretty much self explaining. the part between the [ ] can be left out, it just shows you how to update more than one value. again the limit statement ensures you only alter one set of data.

    hope this helps, if not, get back to me...

    simon

  5. #5
    MdBenner's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Posts
    12

    Re: Form Processors? Or am I looking for something else?

    Hey,

    I forgot one thing: if you want to show me the part of your code that is ot working i will look over it to see if i can spot mistakes...

    simon

  6. #6
    souper's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    4

    Re: Form Processors? Or am I looking for something else?

    Hey,

    Thanks for your help simon!

    I did as you suggest.

    I determined a couple things. Below is the code for my 'update.php' page:

    PHP Code:
    <?
    include("connect.php");
    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");

    $sql "SELECT * FROM links WHERE id = '$id'";
    mysql_query($sql) or die(mysql_error());
    $result mysql_query($sql);
    $num mysql_numrows($result); 
    mysql_close();

    $i=0;
    while (
    $i $num) {
    $url mysql_result($result,$i,"url");
    $name mysql_result($result,$i,"name");

    ?>

    <form action="updated.php">
    <input type="hidden" name="id" value="<? echo "$id"?>">
    URL: <input type="text" name="url" value="<? echo "$url"?>"><br>
    Name: <input type="text" name="name" value="<? echo "$name"?>"><br>
    <input type="Submit" value="Update">
    </form>

    <?
    ++$i;

    ?>
    Code for 'updated.php'

    PHP Code:
    <?
    include("connect.php");
    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Unable to select database");


    $sql "UPDATE links SET url='$url', name='$name' WHERE id = '$id'";
    mysql_query($sql) or die(mysql_error());;
    echo 
    "Record Updated";
    mysql_close();
    ?>
    For some reason, this will NOT work for me. The page will show up as blank. However when I remove 'WHERE id = '$id' from the query string, 'update.php' will show all the fields, but when I hit 'submit', it will execute 'updated.php' and display 'Record Updated', but actually does not make any change to the record. I assume this is because '$id' is not defined somewhere?

    Any ideas?

  7. #7
    MdBenner's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Posts
    12

    Re: Form Processors? Or am I looking for something else?

    Hey,

    there are a couple of things I want to point out right away.

    You have a couple of typos is the code you posted, I hope they are not in the actual code, I don't think so though because you would get a parse error. The first one is in update.php at the mysql_num_rows(); function. The seconde one is in the form when you miss some ; after the echo statements. Last, you have a double ; in your updated.php behing the mysql_query statement.

    As a suggestion for finding the error i recommend adding a statement in the updated.php below the $sql="..."; statement:

    echo ($sql);

    to find out how the query string actually looks.

    One spontaneous source of your error might be in the use of variables. What you should do is use the method argument in your form-tag:

    <form action="updated.php" method="get">

    Then, when you access the vaiebles in the updated.php use this syntax:

    $_GET['key']

    The key is the name of the input field.

    If these changes never work to give you the result you want and you never get an error from mysql_error() then please post the actual value of the $sql variable in updated.php for me (what you get on the screen when you use echo $sql; as described above).

    Simon

  8. #8
    MdBenner's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Posts
    12

    Re: Form Processors? Or am I looking for something else?

    One other typo I just saw now is in the update.php.
    To increment the variable $i you need to use the

    $i++;

    stetement and NOT

    ++$i;

  9. #9
    souper's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    4

    Thumbs up Re: Form Processors? Or am I looking for something else?

    Thank you! Your corrections appeared to have solved the problem.

    That echo ($sql); was very useful.

    Thanks again!

  10. #10
    MdBenner's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2007
    Posts
    12

    Re: Form Processors? Or am I looking for something else?

    You are very welcome...

    Simon



Tags for this Thread