edawg Posted March 23, 2007 Share Posted March 23, 2007 Im trying to build a form using php and mysql, the thing i want to do is have people refer my site to others via email, ive made 6 text boxs like so.. <div class="registration_line">Friends Email: <input type="text" name="picemail1" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail2" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail3" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail4" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail5" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail6" size="30" maxlength="25" /></div><br /> What i want to do is be able to cut down on the code and make name="picemail1" into an array somehow, this is my problem, im not to sure how to implement this, and then call it up in the handle page, ive been using... <div class="registration_line">Friends Email: <input type="text" name="picemail[]" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail[]" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail[]" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail[]" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail[]" size="30" maxlength="25" /></div><br /> <div class="registration_line">Friends Email: <input type="text" name="picemail[]" size="30" maxlength="25" /></div><br /> name="picemail[]" , but when using a foreach loop, i do not get a return??. what can I use??. Quote Link to comment Share on other sites More sharing options...
janroald Posted March 23, 2007 Share Posted March 23, 2007 How does you foreach loop look like? Quote Link to comment Share on other sites More sharing options...
edawg Posted March 23, 2007 Author Share Posted March 23, 2007 How does you foreach loop look like? This is what ive used.. if (!empty($_POST['picemail'])) { $emails() = $_POST['picemail']; foreach ($emails as $value) { echo $value; } ive also tried... if (!empty($_POST['picemail[]'])) { $emails = $_POST['picemail[]']; foreach ($emails as $value) { echo $value; } Also, is there a way I can use a function on an array???. Quote Link to comment Share on other sites More sharing options...
janroald Posted March 23, 2007 Share Posted March 23, 2007 $emails() = meaningless in php $emails = $_POST['picemail[]']; should be $emails = $_POST['picemail']; then your loop will work. There are lots of array functions : http://no.php.net/manual/en/ref.array.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.