rilana Posted April 19, 2008 Share Posted April 19, 2008 Hy guyes I am having a Problem with an output of any array. Could you please help me? I am having an Info Page with the following information that works. <tr> <td colspan="3" valign=top> <span class="inhalt"> smartpersonal gmbh<br><?=$a[sig]?><br>Churerstrasse 20<br>8808 Pfäffikon SZ<br> Tel. 055 417 30 10<br>Fax 055 417 30 19<br><br> </span> <tr> <td height="41" colspan="2" align=center valign="bottom"> <form action=http://www.smartpersonal.ch/contact.php method=post> <input type=hidden name=job_id value=<?=$a[job_id]?>> <input type=hidden name=sig value=<?=$a[sig]?>> <input type=submit name=friend value="Bewerbung über unser Kontaktformular"> </form> </td> <td align=center valign="bottom"><form action=Send.php method=post> <input type=hidden name=job_id value=<?=$a[job_id]?>> <input type=submit name=friend value="an einen Freund senden"> </form></td> </tr> <input type=hidden name=sig value=<?=$a[sig]?>> Is the Person who wrote the Info and the output of this is someting like Rilana Martinato but I am sendeing this Info to a PHP Contact Page which is not connected to the database with the above input hidden..... the Problem now is that when I echo $sig in my contact page it want give me Rilana Martinato it will only output Rilana so basicely it want output the spaces it stops after the first word. What do I need to do now? Is there an easy way? Like another command? When I echo <?=$a[sig]?> nothing works at all, but if I output only $sig, it will only show the first word. Please help me, I would realy aprechiate it! Thanks a lot! Rilana Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/ Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 Always quote attrubute values <input type="hidden" name="sig" value="<?=$a[sig]?>"> Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521087 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 wow that was it!!!!!!!!!! verry cool! thanks so much! Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521092 Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 Please click "Topic solved" Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521094 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 Oh no, I still have a problem! echo "$sig"; if ($sig == "Herr Colin Rhyner") { $myemail= "[email protected]"; } elseif ($sig == "Frau Loan Do") { $myemail= "[email protected]"; } elseif ($sig == "Frau Manuela Jau") { $myemail= "[email protected]"; } else { $myemail= "[email protected]"; } i tryed everything, with "" without "" wich echo without echo... If I put sig = "" on top and then start the if funktion it works, but that's not what I need. What do I need to put bevor the if statement so it will take the sig value? Please help. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521100 Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 <?php if (isset($_POST['sig']) ) // if form submitted, process data { $sig = $_POST['sig'] ; // get hidden form value echo $sig, ' ', myemail($sig); // get the email address } function myemail($sig) { $emails = array ( 'Herr Colin Rhyner' => '[email protected]', 'Frau Loan Do' => '[email protected]', 'Frau Manuela Jau' => '[email protected]' ); return isset($emails[$sig]) ? $emails[$sig] : '[email protected]'; } ?> <?php // // provide sample form data // - for test only // $a = array ('sig' => "Herr Colin Rhyner"); ?> <form method='post'> <input type="hidden" name="sig" value="<?=$a['sig']?>"> <input type="submit" name="btnSub" value="Submit"> </form> Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521112 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 I getting an array send to my contact form. and If I echo $sig it shows that ist's there. But the following if statement does not work. Do I need to say anything bevor I start the if statement? I tryed everything. with and without "" with and without echo... Please help. echo "$sig"; if ($sig == "Herr Colin Rhyner") { $myemail= "[email protected]"; } elseif ($sig == "Frau Loan Do") { $myemail= "[email protected]"; } elseif ($sig == "Frau Manuela Jau") { $myemail= "[email protected]"; } else { $myemail= "[email protected]"; } Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521113 Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 <?php print_r($sig); if ($sig == "Herr Colin Rhyner") { $myemail = "[email protected]"; } elseif ($sig == "Frau Loan Do") { $myemail = "[email protected]"; } elseif ($sig == "Frau Manuela Jau") { $myemail = "[email protected]"; } else { $myemail = "[email protected]"; } ?> ^ What is the output of that? Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521116 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 thanks for your reply the output is correct but it still does not help if I put it in front of the if statement. It ignores it and allways sends the form to else. Do you have any other sugestions? Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521121 Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 thanks for your reply the output is correct but it still does not help if I put it in front of the if statement. It ignores it and allways sends the form to else. Do you have any other sugestions? What is the output!? I need to see it to make sure you're calling the variables properly. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521123 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 Frau Loan Do Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521127 Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 OK post the whole code then please? Or, look in your other thread where Barand has posted a solution. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521129 Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 DON'T double post! I'll close your first one. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521133 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 OK sorry guyes, I thaught since I have a new problem it would be better to open a new post and put the old one on solved... sorry! I am still trying for Barand sucestion. But it doesnt seem to work... it causes an error. I will be back in a fiew minutes with more input on that... thanks for helping. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521137 Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 That would have been fine if you hadn't also added the new problem to your original post Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521140 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 This does not work eighter. The output is nothing and the form gives an error when sending. Please do you have any other solutions? I dont understand if (isset($_POST['sig']) ) // if form submitted, process data Does that simply ask if the previous form has send the array? <?php if (isset($_POST['sig']) ) // if form submitted, process data { $sig = $_POST['sig'] ; // get hidden form value echo $sig, ' ', myemail($sig); // get the email address } function myemail($sig) { $emails = array ( 'Herr Colin Rhyner' => '[email protected]', 'Frau Loan Do' => '[email protected]', 'Frau Manuela Jau' => '[email protected]' ); return isset($emails[$sig]) ? $emails[$sig] : '[email protected]'; } ?> <?php // // provide sample form data // - for test only // $a = array ('sig' => "Herr Colin Rhyner"); ?> Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521142 Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 I dont understand if (isset($_POST['sig']) ) // if form submitted, process data Does that simply ask if the previous form has send the array? Yes. Please define "doesn't work". (It was working when it left the shop) What error does the form give? One thing to try. Put this code in your form processing script so you can see what is being sent echo '<pre>', print_r($_POST, 1), '</pre>'; Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521144 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 Ok I am getting an error e-mail to the right e-mail! I mean the one it requested in the if statement... The error is the following... A message that you sent contained no recipient addresses, and therefore no delivery could be attempted. ------ This is a copy of your message, including all the headers. ------ To: Subject: Kontaktformular X-PHP-Script: www.smartpersonal.ch/contact.php for 91.138.3.198 From: Rilana <[email protected]> Reply-To: Rilana <[email protected]> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="6a9b7f85ad34d1b71c4b1167e5620441" X-Sender: 91.138.3.198 X-Mailer: PHP/5.2.5 X-Priority: 3 Return-Path: <[email protected]> Message-Id: <[email protected]> Date: Sat, 19 Apr 2008 12:46:16 +0200 This is a multi-part message in MIME format. --6a9b7f85ad34d1b71c4b1167e5620441 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable job_id: 356 Firma: Anrede: Herr Name: Rilana Adresse: PLZ: Ort: Telefon: 0764330662 ddd --6a9b7f85ad34d1b71c4b1167e5620441-- Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521148 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 And this is the output with echo '<pre>', print_r($_POST, 1), '</pre>'; Array ( [job_id] => 356 [yourname] => Rilana [firma] => [anrede] => Herr [adresse] => [plz] => [ort] => [telefon] => 0764330662 [youremail] => [email protected] [emailsubject] => [yourmessage] => ddd [submit] => true ) So your code seems to work, but I guess there is some mailserver Problem that comes with it for some reaseon. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521152 Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 There is no "sig" in that list ??? Is the hidden field inside the < form > ... < /form > tags ? Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521153 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 oh this is wierd, why does it get send to the write reciever? anyway it is a pretty complex form because it didn't know how to do an attachement with a form thats why I took this form from a tutorial. it has difined variables for headers and message. //Headers $headers="From: ".$yourname." <".$youremail.">\n"; $headers.="Reply-To: ".$yourname." <".$youremail.">\n"; $headers.="MIME-Version: 1.0\n"; $headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n"; $headers.="X-Mailer: PHP/".phpversion()."\n"; $headers.="X-Priority: ".$priority."\n"; $headers.="Return-Path: <".$youremail.">\n"; $headers.="This is a multi-part message in MIME format.\n"; //Message $message = "--".$boundary."\n"; $message.="Content-Type: text/plain; charset=\"iso-8859-1\"\n"; $message.="Content-Transfer-Encoding: quoted-printable\n"; $message.="\n"; $message.="job_id: $job_id"; $message.="\n"; $message.="Firma: $firma"; $message.="\n"; $message.="Anrede: $anrede"; $message.="\n"; $message.="Name: $yourname"; $message.="\n"; $message.="Adresse: $adresse"; $message.="\n"; $message.="PLZ: $plz"; $message.="Ort: $ort"; $message.="\n"; $message.="Telefon: $telefon"; $message.="\n"; $message.="$yourmessage"; $message.="\n"; do I need to ad $sig there? Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521154 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 Now I did add the $sig variable. The output looks like that now Array ( [job_id] => 356 [$sig] => Frau Loan Do [yourname] => Rilana [firma] => [anrede] => Herr [adresse] => [plz] => [ort] => [telefon] => 0764330662 [youremail] => [email protected] [emailsubject] => [yourmessage] => t [submit] => true ) $sig is there but the error still exists. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521159 Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 Get rid of the $ before it. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521160 Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 Sorry I dont understand what you mean. Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521166 Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 In your HTML form, instead of name="$sig" use name="sig" Link to comment https://forums.phpfreaks.com/topic/101831-solved-problem-with-array-and-if-statement/#findComment-521169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.