Results 1 to 5 of 5
  1. #1

    Post PHP contact form script

    Hey guys. Apologies if I am repeating a question or posting this in the wrong place.

    Ive just started learning PHP and need some guidance.

    I have created a contact form with various fields.
    I have a MYSQL Dbase that is populated.

    I want to present a form to a user with some fields pre-populated from my db.

    1)<th><div align="left">Position:</div></th>
    <td><input name="position" type="text" class="textfield" value= "" id="position" size="25" maxlength="25" /></td>

    How would I populate the VALUE FIELD directly from my db?

    Help would me much appreciated..

  2. #2
    Firstly your need to connect database in php.

    mysql_connect(HOSTNAME, USERNAME, USER PASS);
    mysql_select_db(DATABASE NAME);

    Read articles about mysql functions in php. It's easy to use.

  3. #3

    Maybe I was a bit vague.

    I have a working db, connected etc. My form works when manually input'ed with info.

    What I am trying to achieve is this.
    I have saved to my db records: say "CARS" - BMW, Ferrari etc...
    I have a contact form for users who have browsed my cars and are interested in say - Purchasing one.

    However on my php web page where you browse the cars, I have a link next to each car that opens a single page with info of that car only together with a contact form on that page.

    Should the user be interested in the car he is currently browsing, he needs to fill in the form! "The form is a standard contact form" with fields one of which is a position field which I would like prefilled when he browses that car.

  4. #4
    Join Date
    Oct 2002
    State of Disbelief
    Write a query that pulls in the car info for that page, assign it to a variable and use that to populate that field. Assuming you've queried and pulled the data you need, assigning it to $car:

    <td><input name="position" type="text" class="textfield" value= "<?php $car; ?>" id="position" size="25" maxlength="25" /></td>
    Having problems, or maybe questions about WHT? Head over to the help desk!

  5. #5
    In sql your query you can search that table for any matching content:
    WHERE cars LIKE "%$cars%"
    Web Hosting by Brontobytes

Similar Threads

  1. HTML Contact Form with PHP script for email and SMS alerts
    By tomastamm in forum Software & Scripts Offers
    Replies: 0
    Last Post: 07-17-2013, 12:57 AM
  2. Paypal contact form script
    By bambinou in forum Programming Discussion
    Replies: 5
    Last Post: 01-23-2011, 12:12 PM
  3. PHP formail/contact form script that uses SMTP authentication?
    By hilda in forum Programming Discussion
    Replies: 3
    Last Post: 05-18-2007, 04:43 PM
  4. PHP Form Script Help, Please.
    By theecho in forum Web Design and Content
    Replies: 10
    Last Post: 01-14-2005, 09:11 PM
  5. PHP Script to act as middleman between HTML Form and CGI Script
    By DynamicHost in forum Programming Discussion
    Replies: 2
    Last Post: 01-12-2005, 02:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts