Re: Form Processing

From: Date: Tue, 30 Nov 2010 10:58:18 +0000
Subject: Re: Form Processing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-309764@lists.php.net to get a copy of this message
On 29/11/10 23:54, Ron Piggott wrote:
I am unable to retrieve the value of $referral_1 from: $new_email = mysql_escape_string ( $_POST['referral_$i'] ); why? PHP while lopp to check if any of the fields were populated: $i=1; while ( $i<= 5 ) {
     $new_email = mysql_escape_string ( $_POST['referral_$i'] );
     if ( strlen ( $new_email )>  0 ) {
....
     }
} The form itself: <form method="post" action=”website”> <p style="margin: 10px 50px 10px 50px;"><input type="text" name="email" maxlength="60" class="referral_1" style="width: 400px;"></p> <p style="margin: 10px 50px 10px 50px;"><input type="text" name="email" maxlength="60" class="referral_2" style="width: 400px;"></p> <p style="margin: 10px 50px 10px 50px;"><input type="text" name="email" maxlength="60" class="referral_3" style="width: 400px;"></p> <p style="margin: 10px 50px 10px 50px;"><input type="text" name="email" maxlength="60" class="referral_4" style="width: 400px;"></p> <p style="margin: 10px 50px 10px 50px;"><input type="text" name="email" maxlength="60" class="referral_5" style="width: 400px;"></p> <p style="margin: 10px 50px 10px 50px;"><input type="submit" name="submit" value="Add New Referrals"></p> </form> What am I doing wrong? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
The Daniels are on the right track, but not very clear: First, the <input> elements all have the 'name' attribute set to 'email' and the 'class' set to 'referral_1' etc. - I think you have that the wrong way round! Second, using single quotes in the $_POST['referral_$i'] bit will not work (DPB is right there) - use $_POST['referral_'.$i] or $_POST["referral_$i"] -- Peter Ford, Developer phone: 01580 893333 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS

« previous php.general (#309764) next »