Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2006, 08:43 AM
Authorized User
 
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mark jonas
Default emailing form information

ok i no the basics of php as i have been looking at in for about a month now but i cant seem to work this out i have a form like

<form name="Voting2006" method="POST" action="toscriptpage" title="Voting 2006">
//used to be able to find the other name fields.
<input type="hidden" name="required" value="groupButton, food" />
//what ever name fields the user wonts
<input type="text" name="food" Value="it works" />
<input type="text" name="groupButton" Value="barrattTyGlas" />
<input type="submit" name="Submit" value="Register my vote" />
</form>

which posts to this code

$required = $_POST['required'];
$require = split(",",$required);
foreach($require as $values){
  $value = preg_replace('/[\\ \-_\/]/', '', $values);
  echo $_POST[$value];}

which works and displays the two users inputs on the screen but what i wont to do is sent this in an email so i tryed

$required = $_POST['required'];
$require = split(",",$required);
foreach($require as $values){
  $value = preg_replace('/[\\ \-_\/]/', '', $values);
  $fields = "$_POST[$value]<br />";}
mail(all information you need filed in correct);

then for the email body i added the $fields Where i wonted it but it only sends the last input input value in this case being "it works" im geussing im going the wrong way about this.
so after seaching around i havent really found anything which will allow this have play with arrays a little but have had no luck so if someone could point me in the right direction that would be great.As im not 100% shore on another way i might be able to do this.

hope this is clear thanks in advance
mark


 
Old November 15th, 2006, 02:58 PM
Registered User
 
Join Date: Nov 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

$fields is just a variable not an array so you are changing it each time round the loop. and at the end it will just be set to the last value.

if you want it to be an array then you need to do something like:

$i=0;
foreach($require as $values){
  $value = preg_replace('/[\\ \-_\/]/', '', $values);
  $fields[$i] = "$_POST[$value]<br />";
  $i++;
}

or else to just have 1 big string you could do:

foreach($require as $values){
  $value = preg_replace('/[\\ \-_\/]/', '', $values);
  $fields .= "$_POST[$value]<br />";
}


 
Old November 16th, 2006, 05:54 AM
Authorized User
 
Join Date: Nov 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mark jonas
Default

bluenose thank you very much i cant belive it was something as simply as that really.

but htanks again at least i no now

cheers
mark:D






Similar Threads
Thread Thread Starter Forum Replies Last Post
how I can search required information form table GeoIrshad Access VBA 1 March 13th, 2008 06:31 AM
Auto-Emailing hafizism Excel VBA 1 October 29th, 2004 09:43 AM
Inserting Information From Form into another Table smartgir Access VBA 6 October 22nd, 2004 12:35 AM
updating table information with a form? lanctotd Access 1 June 8th, 2004 12:46 PM
Obtaining information from a form Ashleek007 PHP How-To 1 March 1st, 2004 09:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.