/    Sign up×
Community /Pin to ProfileBookmark

Need help on HTML to PHP

i’ve completed my contact form.html , i need a working php form to fetch all the content.

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmApr 14.2015 — Glad to hear you want to get into using php. So now the task is to write some php and THEN ask for help fixing it.
Copy linkTweet thisAlerts:
@jedaisoulApr 14.2015 — One piece of advice:

An easy way to pass success/failure flag and/or prompt for re-input back to the form is to embed the PHP script in the input form. You can do that by:

  • 1. Setting the form action to "#".

  • 2. Naming the submit input.

  • 3. Testing for the submit.

  • 4. Coding as appropriate...
  • Copy linkTweet thisAlerts:
    @Bruce_AthertonApr 15.2015 — There are actually free converter that can find online. Have you tried checking? Thank you.
    Copy linkTweet thisAlerts:
    @ginerjmApr 15.2015 — "Embed the php script in the input form"? I'm sure the English is lacking here.
    Copy linkTweet thisAlerts:
    @nongtinh3Apr 15.2015 — Have you tried checking? Thank you.
    Copy linkTweet thisAlerts:
    @jedaisoulApr 15.2015 — "Embed the php script in the input form"? I'm sure the English is lacking here.[/QUOTE]
    Well, I should have said "embed the PHP script in the web page containing the input form". Does that make more sense?
    Copy linkTweet thisAlerts:
    @shiny012Apr 20.2015 — <html>

    <body>

    <form action="update_2232.php" method="post">

    <h3>Code:</h3>

    <input type="text" name="officeCode">

    <h3>Name:</h3>

    <input type="text" name="name">

    <input type="submit">

    </form>

    </body>

    </html>

    <?php

    //Connecting to sql db.

    mysql_connect('localhost', 'mysql_user', 'mysql_password') or die(mysql_error());

    mysql_select_db("test") or die(mysql_error());

    //Sending form data to sql db.

    mysqli_query($connect,"INSERT INTO office (officeCode, name)

    VALUES ('601', 'Boora')");

    ?>
    Copy linkTweet thisAlerts:
    @ginerjmApr 20.2015 — Dear shiny,

    Is this code supposed to help the OP in understanding how to grab incoming form data and how to PROPERLY post it to a db using CURRENT technology? Cause if it is, it's not a very nice example of how things s/b done.

    If I were the OP I'd be wondering:

    1 - how do my form fields get into that query in a safe sanitized way?

    2 - Is MySQL the best interface to use to connect to my db?

    3 - How do I know that any of my code actually works? Shouldn't I be doing some error checking?

    4 - What do I do when the update is complete? How will my user know?
    Copy linkTweet thisAlerts:
    @rootApr 22.2015 — @shiny012

    Your example has errors in it and it does not assist with the OP's needs.

    @vickytanghm

    As you have been advised, your form will need to "call" a PHP script as some people put it or the alternative is to make one PHP page that will display the form and also process the form.

    Easiest is to have your form send it data to the processing script.

  • 1. You will need to first off get your script working

  • 2. You will then need to ensure it is secure

  • 3. You will need to implement measures to ensure that your processor page is not being sent data outside of your form like a spam bot.

  • 4. You will then need to clean any input and make it ready for insertion in to your chosen database.


  • At the moment, you only need to worry about point 1.
    ×

    Success!

    Help @vickytanghm spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.29,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...