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 Quote Link to comment 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]?>"> Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Barand Posted April 19, 2008 Share Posted April 19, 2008 Please click "Topic solved" Quote Link to comment 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= "crhyner@smartpersonal.ch"; } elseif ($sig == "Frau Loan Do") { $myemail= "rila@rilana.biz"; } elseif ($sig == "Frau Manuela Jau") { $myemail= "mjau@smartpersonal.ch"; } else { $myemail= "rila@freesurf.ch"; } 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. Quote Link to comment 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' => 'crhyner@smartpersonal.ch', 'Frau Loan Do' => 'rila@rilana.biz', 'Frau Manuela Jau' => 'mjau@smartpersonal.ch' ); return isset($emails[$sig]) ? $emails[$sig] : 'rila@freesurf.ch'; } ?> <?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> Quote Link to comment 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= "c@personal.ch"; } elseif ($sig == "Frau Loan Do") { $myemail= "rila@ril.biz"; } elseif ($sig == "Frau Manuela Jau") { $myemail= "mjau@personal.ch"; } else { $myemail= "rila@fre.ch"; } Quote Link to comment 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 = "c@personal.ch"; } elseif ($sig == "Frau Loan Do") { $myemail = "rila@ril.biz"; } elseif ($sig == "Frau Manuela Jau") { $myemail = "mjau@personal.ch"; } else { $myemail = "rila@fre.ch"; } ?> ^ What is the output of that? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
rilana Posted April 19, 2008 Author Share Posted April 19, 2008 Frau Loan Do Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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' => 'crhyner@smartpersonal.ch', 'Frau Loan Do' => 'rila@rilana.biz', 'Frau Manuela Jau' => 'mjau@smartpersonal.ch' ); return isset($emails[$sig]) ? $emails[$sig] : 'rila@freesurf.ch'; } ?> <?php // // provide sample form data // - for test only // $a = array ('sig' => "Herr Colin Rhyner"); ?> Quote Link to comment 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>'; Quote Link to comment 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 <rila@rilana.biz> Reply-To: Rilana <rila@rilana.biz> 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: <rila@rilana.biz> Message-Id: <E1JnAaG-000Je1-Cy@server28.hostpoint.ch> 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-- Quote Link to comment 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] => rila@rilana.biz [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. Quote Link to comment 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 ? Quote Link to comment 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? Quote Link to comment 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] => rila@rilana.biz [emailsubject] => [yourmessage] => t [submit] => true ) $sig is there but the error still exists. Quote Link to comment Share on other sites More sharing options...
chigley Posted April 19, 2008 Share Posted April 19, 2008 Get rid of the $ before it. Quote Link to comment 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. Quote Link to comment 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" 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.