Jump to content


Photo

Help with Form Validation


  • Please log in to reply
3 replies to this topic

#1 DBookatay

DBookatay
  • Members
  • PipPipPip
  • Advanced Member
  • 334 posts
  • LocationCT

Posted 10 May 2006 - 06:06 AM

This is a very new-B question, but can someone show me a working code that will return an error message if required fields are not filled in?

I built a 2 part form, new.php and order.php, and when someone enters info into new.php it is passed along to order.php as hidden fields, then instered into my db. What I now need to do is make the form fields required, but cant get that hang of it. And I have tried and tried and tried...

If someone can show me an example I would REALLY apprechiate it.

<?php
    include ('../common/include/header.php');
    include_once ("../auth.php");
    include_once ("../authconfig.php");
    include_once ("../check.php");
?>
        <td class="lftNavHldr" rowspan="2">
            <?php include ('../common/include/lftNav_Vendor.php'); ?>
        </td>
        <td class="mainNavBlank">Logged in as: <span class="user"><? echo $USERNAME; ?></span></td></tr>
        <tr>
            <td class="main">
                <table>
                    <tr><td class="hdr">Post A New Add</td></tr>
                    <tr>
                        <td class="index">
                            <div class="form">

                            <form name="form1" method="post" action="order.php">
                            <table>
                                <tr>
                                    <td>Primary Trade Channel:</td>
                                    <td rowspan="2"><img src="../common/images/spacer.gif" width="20" height="1" /></td>
                                    <td>Secondary Trade Channel:</td>
                                </tr>
                                <tr>
                                    <td class="inptHldr">
                                        <select class="DropDown" name="Primary_Trade">
                                            <option></option>
                                            <option value="Accessories">Accessories</option>
                                            <option value="Automotive">Automotive</option>
                                            <option value="Beauty">Beauty Supplies</option>
                                            <option value="Bedding">Bedding</option>
                                            <option value="Computer">Computer/Software/Peripherals</option>
                                            <option value="Electronics">Consumer Electronics</option>
                                            <option value="Fashion">Fashion</option>
                                            <option value="Food">Food & Drug</option>
                                            <option value="Furniture">Furniture</option>
                                            <option value="Garden">Garden</option>
                                            <option value="Giftware">Giftware</option>
                                            <option value="Healthcare">Healthcare/OTC</option>
                                            <option value="Doctor">Healthcare/Doctor/Detailing/Hospital</option>
                                            <option value="Home">Home Improvement</option>
                                            <option value="Housewares">Housewares</option>
                                            <option value="Jewelry">Jewelry</option>
                                            <option value="Luggage">Luggage</option>
                                            <option value="Outdoor">Outdoor</option>
                                            <option value="Pet">Pet Supply</option>
                                            <option value="Security">Security</option>
                                            <option value="Sports">Sporting Goods</option>
                                            <option value="Travel">Travel</option>
                                        </select>
                                    </td>
                                    <td class="inptHldr">
                                        <select class="DropDown" name="Secondary_Trade">
                                            <option></option>
                                            <option value="Accessories">Accessories</option>
                                            <option value="Automotive">Automotive</option>
                                            <option value="Beauty">Beauty Supplies</option>
                                            <option value="Bedding">Bedding</option>
                                            <option value="Computer">Computer/Software/Peripherals</option>
                                            <option value="Electronics">Consumer Electronics</option>
                                            <option value="Fashion">Fashion</option>
                                            <option value="Food">Food & Drug</option>
                                            <option value="Furniture">Furniture</option>
                                            <option value="Garden">Garden</option>
                                            <option value="Giftware">Giftware</option>
                                            <option value="Healthcare">Healthcare/OTC</option>
                                            <option value="Doctor">Healthcare/Doctor/Detailing/Hospital</option>
                                            <option value="Home">Home Improvement</option>
                                            <option value="Housewares">Housewares</option>
                                            <option value="Jewelry">Jewelry</option>
                                            <option value="Luggage">Luggage</option>
                                            <option value="Outdoor">Outdoor</option>
                                            <option value="Pet">Pet Supply</option>
                                            <option value="Security">Security</option>
                                            <option value="Sports">Sporting Goods</option>
                                            <option value="Travel">Travel</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr><td colspan="3">Product Title:</td></tr>
                                <tr><td class="inptHldr" colspan="3"><input class="Input" type="text" name="Product_Title" size="78" maxlength="255" /></td></tr>

                                <tr><td colspan="3">Description of product:</td></tr>
                                <tr><td class="inptHldr" colspan="3"><textarea name="Product_Description" class="TextArea" rows="9" cols="80"></textarea></td></tr>

                                <tr><td colspan="3">Description of Engagement:</td></tr>
                                <tr><td class="inptHldr" colspan="3"><textarea name="Engagement_Description" class="TextArea" rows="5" cols="80"></textarea></td></tr>

                                <tr>
                                    <td colspan="5">
                                        <table>
                                            <tr>
                                                <td>Contact Name:</td>
                                                <td rowspan="2"><img src="../images/spacer.gif" width="20" height="1" /></td>
                                                <td>Title:</td>
                                            </tr>
                                            <tr>
                                                <td class="inptHldr"><input class="Input" type="text" name="Contact_Name" size="33" maxlength="100" /></td>
                                                <td class="inptHldr"><input class="Input" type="text" name="Contact_Title" size="33" maxlength="100" /></td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>

                                <tr><td class="dots" colspan="3"><image src="../images/spacer.gif" height="18" width="1" /></td></tr>
                                <tr><td class="btnHldr" colspan="3"><input type="image" src="../images/BTN_Go.gif" name="submit" border="0" /></td></tr>
                            </table>
                            </form>

                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

<?php
    include ('../common/include/footer.php');
?>


$result mysql_query("SELECT finger FROM hand WHERE id=3"); 
echo 
$result


#2 Guest_askjames01_*

Guest_askjames01_*
  • Guests

Posted 10 May 2006 - 06:55 AM

[img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]

here study this link --> [a href=\"http://www.php-mysql-tutorial.com/form-validation-with-php.php\" target=\"_blank\"]The validation form.[/a]


GOOD LUCK!

#3 DBookatay

DBookatay
  • Members
  • PipPipPip
  • Advanced Member
  • 334 posts
  • LocationCT

Posted 10 May 2006 - 06:58 AM

[!--quoteo(post=372839:date=May 10 2006, 02:55 AM:name=askjames01)--][div class=\'quotetop\']QUOTE(askjames01 @ May 10 2006, 02:55 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
[img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /]

here study this link --> [a href=\"http://www.php-mysql-tutorial.com/form-validation-with-php.php\" target=\"_blank\"]The validation form.[/a]
GOOD LUCK!
[/quote]


I'd like to do it via PHP not java scripts....
Thanks anyway though!

$result mysql_query("SELECT finger FROM hand WHERE id=3"); 
echo 
$result


#4 GarethMarijt

GarethMarijt
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 10 May 2006 - 12:28 PM

[!--quoteo(post=372840:date=May 10 2006, 07:58 AM:name=DBookatay)--][div class=\'quotetop\']QUOTE(DBookatay @ May 10 2006, 07:58 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'd like to do it via PHP not java scripts....
Thanks anyway though!
[/quote]
I am a bit new to this so please make allowances...
I had a similar problem which I resolved by merging the two pages:
Please note - this not the actual code, rather a summary of the method
<?php
function validated()
{
if (isset($_REQUEST['input_callref'])) //and any other checks you need
return true;
else
return false;
}
if (validated())
{
//Contents of order.php
}
else
{
?>
<form method="post" name="data_capture" action="<?php echo $_SERVER['PHP_SELF'] ?>"
<!-- Contents of new.php e.g. -->
<input type="text" name="input_callref" size="15" tabindex="1">
</form>
<?php
}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users