SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: PHP form help

  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP form help

    How do I receive just the field results of this php form/script that is filled in by the customer?
    Currently I receive all fields whether they are filled in or not (makes it harder to quickly read the results).
    Script: www.ihost-websites.com/formmail.phps
    Form: www.homefinders.com/contact_us.php
    Thanks,
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to first check that there is some kind of data in the FORM element(s) yes ?

    PHP Code:
    ...
    <
    input type='text' size='16' name='User' maxlength='32' />
    ... 
    Then something simple like this ?

    PHP Code:
    if(empty($_POST['User']) || $_POST['User'] == (string) '') {
    echo(
    'Please complete the username field'); 

    For example ? Though to be honest you'd be better to use Reg Exp on any input's regardless of what the FORM is for...

    Number one rule with FORMs; Never trust the user

  3. #3
    SitePoint Addict Resident Evil's Avatar
    Join Date
    May 2003
    Location
    Barrow
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if($user == "") {
    echo('Please Enter Username');
    }

  4. #4
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, now where/how do I exactly enter the code in the script?

    Keep in mind I am no php programmer so would need more details
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  5. #5
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the form I am using:

    <form method=post action="http://www.homefinders.com/formmail.php">
    <input type=hidden name="recipient" value=info@ihost-websites.com>
    <input type=hidden name="subject" value="Homefinders Information Request">
    <input type=hidden name="required" value="realname,email">
    <input type=hidden name="redirect" value="http://www.homefinders.com/thanks.htm">
    <input type=hidden name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT,REMOTE_IDENT">
    <input type=hidden name="sort" value="order:realname,address1,address2,phone,work_phone,city,state,zip,email,price,date,type,saletype,comments">

    <table width="62%" border="0" align="center" cellpadding="3" cellspacing="3">

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><table width="98%" border="0" cellspacing="3" cellpadding="3">
    <tr>
    <td width="93%"><p>Yes, I would like
    help with my home search. </p></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td><table width="80%" border="0" cellspacing="3" cellpadding="3">
    <tr>
    <td width="26%"><div align="right">
    <p>Name/p>
    </div></td>
    <td width="74%"><input name="realname" type="text" id="name" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>Day Phone/p>
    </div></td>
    <td><input name="day_phone" type="text" id="day_phone" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>Evening Phone/p>
    </div></td>
    <td><input name="evening_phone" type="text" id="evening_phone" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>E-mail/p>
    </div></td>
    <td><input name="email" type="text" id="email" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>Home Address/p>
    </div></td>
    <td><input name="address" type="text" id="address" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>Apt. Number/p>
    </div></td>
    <td><input name="apt_number" type="text" id="apt_number" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>City/p>
    </div></td>
    <td><input name="city" type="text" id="city" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>State/p>
    </div></td>
    <td><input name="state" type="text" id="state" size="30"></td>
    </tr>
    <tr>
    <td><div align="right">
    <p>Zip Code/p>
    </div></td>
    <td><input name="zip_code" type="text" id="zip_code" size="15"></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><table width="407" border="0" cellspacing="3" cellpadding="3">
    <tr>
    <td width="133"><p align="left">What's
    My Price Range/p></td>
    <td width="253"><select name="select">
    <option value="No Selection">No
    Selection</option>
    <option value="$100,000 to $200,000">$100,000
    to $200,000</option>
    <option value="$200,000 to $300,000">$200,000
    to $300,000</option>
    <option value="$300,000 to $400,000">$300,000
    to $400,000</option>
    <option value="$500,000 to $700,000">$500,000
    to $700,000</option>
    <option value="Over $700,000">Over
    $700,000</option>
    </select></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>Type of home desired/p></td>
    </tr>
    <tr>
    <td><table width="80%" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
    <td><input name="No_Selection" class="checkbox" type="checkbox" id="No_Selection" value="No_Selection_type" checked></td>
    <td><p>No Selection</p></td>
    </tr>
    <tr>
    <td><input name="Condominium" class="checkbox" type="checkbox" id="Condominium" value="Condominium"></td>
    <td><p>Condominium</p></td>
    </tr>
    <tr>
    <td><input name="Town_Home" class="checkbox" type="checkbox" id="Town_Home" value="Town_Home"></td>
    <td><p>Town Home</p></td>
    </tr>
    <tr>
    <td height="26"> <input name="Single_Detached" class="checkbox" type="checkbox" id="Single_Detached" value="Single_Detached"></td>
    <td><p> Detached Single Family</p></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>I plan to buy a home in/p></td>
    </tr>
    <tr>
    <td><table width="80%" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
    <td width="13%"><input name="No_Selection2" class="checkbox" type="checkbox" id="No_Selection_Purchase_Date" value="No_Selection_Purchase_Date" checked></td>
    <td width="87%"><p>No Selection</p></td>
    </tr>
    <tr>
    <td><input name="immediately" type="checkbox" class="checkbox" id="Purchase_Date_immediately" value="Purchase_Date_immediately"></td>
    <td><p>Immediately</p></td>
    </tr>
    <tr>
    <td><input name="3_months" class="checkbox" type="checkbox" id="Purchase_Date_3_months" value="Purchase_Date_3_months">
    </td>
    <td><p>3 Months</p></td>
    </tr>
    <tr>
    <td height="21"> <input name="6_months" class="checkbox" type="checkbox" id="Purchase_Date_6_months" value="Purchase_Date_6_months"></td>
    <td><p>6 Months</p></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>The type of home I plan to buy/p></td>
    </tr>
    <tr>
    <td><table width="80%" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
    <td width="13%"><input name="No_Selection_type" class="checkbox" type="checkbox" id="No_Selection2" value="No_Selection_Type" checked></td>
    <td width="87%"><p>No Selection</p></td>
    </tr>
    <tr>
    <td><input name="Resale_or_New" type="checkbox" class="checkbox" id="immediately" value="Resale_or_New"></td>
    <td><p>Resale or New</p></td>
    </tr>
    <tr>
    <td><input name="Resale" class="checkbox" type="checkbox" id="3_months" value="Resale">
    </td>
    <td><p>Resale Only</p></td>
    </tr>
    <tr>
    <td height="21"> <input name="New" class="checkbox" type="checkbox" id="6_months" value="New"></td>
    <td><p>New Only</p></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>I am particularly interested in homes
    in the following areas/p></td>
    </tr>
    <tr>
    <td><table width="80%" border="0" align="center" cellpadding="3" cellspacing="3">
    <tr>
    <td width="13%"><input name="No_Selection222" class="checkbox" type="checkbox" id="No_Selection22" value="No_Selection_Area" checked></td>
    <td width="87%"><p>No Selection</p></td>
    </tr>
    <tr>
    <td><input name="Area_Maryland" type="checkbox" class="checkbox" id="Resale_or_New" value="Maryland"></td>
    <td><p>Maryland</p></td>
    </tr>
    <tr>
    <td><input name="Area_Virginia" class="checkbox" type="checkbox" id="Resale" value="Virginia">
    </td>
    <td><p>Virginia</p></td>
    </tr>
    <tr>
    <td height="21"> <input name="Area_Maryland_or_Virginia" class="checkbox" type="checkbox" id="New" value="Maryland_or_Virginia"></td>
    <td><p>Maryland or Virginia</p></td>
    </tr>
    </table></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p><strong>I am particularly interested
    in the following areas/strong></p></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>Maryland areas Homefinders.com serves/p></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><div align="center">
    <select size="5" name="MD_Areas" id="MD_Areas" multiple style="width: 50%">
    <option value="No Selection " selected>No Selection
    Made</option>
    <option value="Anne Arundel">Anne Arundel</option>
    <option value="Baltimore City">Baltimore City</option>
    <option value="Baltimore County">Baltimore County</option>
    <option value="Calvert County">Calvert County</option>
    <option value="Carroll County">Carroll County</option>
    <option value="Charles County">Charles County</option>
    <option value="Harford County">Harford County</option>
    <option value="Howard County">Howard County</option>
    <option value="Frederick County">Frederick County</option>
    <option value="Kent County">Kent County</option>
    <option value="Montgomery County">Montgomery County</option>
    <option value="Prince George's County">Prince George's
    County</option>
    <option value="Talbot County">Talbot County</option>
    <option value="St. Mary's County">St. Mary's County</option>
    <option value="1Queen Anne's County">Queen Anne's County</option>
    <option value="Eastern Shore Other">Eastern Shore Other</option>
    </select>
    </div></td>
    </tr>
    <tr>
    <td><div align="center">
    <p class="small"><font color="#000066">To
    make multiple selections, use &quot;crtl&quot;
    + click.</font></p>
    </div></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>Virginia areas Homefinders.com serves/p></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td> <div align="center">
    <select size="5" name="VA_Areas" id="VA_Areas" multiple style="width: 50%">
    <option value="No Selection" selected>No Selection
    Made</option>
    <option value="Alexandria City">Alexandria City</option>
    <option value="Arlington County">Arlington County</option>
    <option value="Culpeper County">Culpeper County</option>
    <option value="Fairfax County">Fairfax County</option>
    <option value="Fauquier County">Fauquier County</option>
    <option value="Loudoun County">Loudoun County</option>
    <option value="Prince William County">Prince William County</option>
    <option value="Spotsylvania County">Spotsylvania County</option>
    <option value="Stafford County">Stafford County</option>
    <option value="King George County">King George County</option>
    <option value="Westmorland County">Westmorland County</option>
    </select>
    </div></td>
    </tr>
    <tr>
    <td><div align="center">
    <p class="small"><font color="#000066">To
    make multiple selections, use &quot;crtl&quot;
    + click.</font></p>
    </div></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><p>Please tell us any important information
    about your needs/p></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><table width="100%" border="0" cellspacing="3" cellpadding="3">
    <tr>
    <td><div align="center">
    <textarea name="special_needs" cols="35" rows="5"></textarea>
    </div></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><div align="center">
    <input type="submit" name="Submit" value="Submit Form">
    </div></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </form>
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting

  6. #6
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vision2000
    Thanks, now where/how do I exactly enter the code in the script?
    It should be included in the beginning of your form.php script, but that script has an error function which I'm guessing it checks for empty fields. Not sure though.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine

  7. #7
    SitePoint Evangelist
    Join Date
    Jan 2001
    Posts
    478
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply Toly, I think I got it working.
    Herman Drost
    http://www.isitebuild.com
    Affordable Web Site Design
    and Web Site Hosting


Bookmarks

Posting Permissions

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