PHP code for return button

need PHP code to insert button or link

Page 1 of 1

7 Replies - 8630 Views - Last Post: 06 August 2008 - 06:20 PM Rate Topic: -----

#1 bazzdaciple  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-August 08

PHP code for return button

Posted 04 August 2008 - 05:33 AM

hello all!
I have a PHP code that can be used for contact forms. In the end, when the visitor of my page has inputted his name, e-mail and message content en clicks on SEND the mail is send to my mailaccount. so fas so good, but then a echo message is displayed thanking the person for sending his mail. At that point I would like to see below that remark a button which will lead the visitor back to my homepage (index). There now is a link, with javascript, sending the person back one page, which again is the contact form. But I need the person to go back to the index.

What PHP code should I use for the link?

Is This A Good Question/Topic? 0
  • +

Replies To: PHP code for return button

#2 Moonbat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Re: PHP code for return button

Posted 04 August 2008 - 07:43 AM

If you really want to do it in PHP...

<?php
echo "<a href=/"index.php/">Back to the homepage</a>";
?>

Was This Post Helpful? 0
  • +
  • -

#3 bazzdaciple  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-August 08

Re: PHP code for return button

Posted 05 August 2008 - 03:01 AM

HI

thanks for all help. I tried to input the link but what happens is that I immediately get a error when I change the code (see below for the code).
I entered the following line

echo "<br>Klik om terug te gaan <a href="/index.html">/ Click to return</a></br>";


I entered this code below this line in the code:

echo "<b>Bedankt voor uw inzending / thank you for submitting your message</b>"; 
     }


(just to clarify. I am Dutch and the first part of the link says thank you in Dutch and then in English)

when I add the a href line, I get an error when clicking on send. when I delete the line the message is send.

PLEASE FIND BELOW THE CODE:

<? 
if(!empty($_POST['Submit']))
{ 
if(strlen($_POST['name']) == 0)
    { $error_msg =" U heeft uw naam niet ingevuld / your name was not entered<br>"; } 
if(!ereg("^[_a-zA-Z0-9-]+(\.[*@([a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$", $_POST['uwemail']))
    { $error_msg .=" Het ingevoerde mailadres lijkt niet correct / entered mailaddress not valid<br>"; } 
if(strlen($_POST['field']) ==0)
    { $error_msg .=" U heeft geen bericht ingevoerd / no message entered<br>"; } 
    
if(!empty($error_msg))
    { 
    echo "<b>Bericht niet verzonden om volgende reden... / Mail did not go trough because....</b><br><br>"; 
    echo $error_msg; 
    echo "<br>Klik hier om opnieuw in te voeren / click to re-enter  <a href=java script:history.back(1)>terug / return</a> <br><br>"; 
    }
else 
    { 
    $recipient = "info@alidus.nl"; 
    $subject = $sub; 
    $header = "From: " . $uwemail . "\n"; 
    $mail_body = "Contact script werd op " . date("d-m-Y") . " om " . date("H:i") . " uur uitgevoerd.\n"; 
    $mail_body .= "De volgende persoon vulde het contact formulier in:\n\n"; 
    $mail_body .= "Naam: " . $_POST['name'] . "\n"; 
    $mail_body .= "E-mailadres: " . $_POST['uwemail'] . "\n\n"; 
    $mail_body .= "Bericht:\n"; 
    $mail_body .= $_POST['field']; 
    $mail_body .= "\n\n -- Einde van het contact bericht --"; 
    mail($recipient, $subject, $mail_body, $header); 
    echo "<b>Bedankt voor uw inzending / thank you for submitting your message</b>"; 
     }
} 
else 
{ 
?><body bgcolor="#2C172F"> 
<form action="contact/contact.php" method="POST" name="contact"> 
  <table width="90%" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
      <td><br> 
        <table width="73%" height="50" border="0" align="center" cellpadding="0" cellspacing="0"> 
          <tr> 
            <td height="1" colspan="2"><div align="center">
              <p><font size="5"><strong><font color="#FFFFCC">CONTACT ALIDUS FIJNPROEVERIJ</font></strong></font></p>
              <p>&nbsp;</p>
            </div></td> 
          </tr> 
          <tr> 
            <td height="1"><p><font color="#FFFFFF" size="4">Naam / Name</font></p>
            <p>&nbsp;</p></td> 
            <td width="423" height="2"> <p>
              <input type="text" name="name" size="40">
            </p>
              <p>&nbsp; </p></td> 
          </tr> 
          <tr> 
            <td height="1"><p><font color="#FFFFFF" size="4">E-mail </font></p>
            <p>&nbsp;</p>
            <p>&nbsp;</p></td> 
            <td height="2"> <p>
              <input type="text" name="uwemail" size="40">
            </p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
            </td> 
          </tr> 
          <tr> 
            <td width="205" class="Kleiner"><p><font color="#FFFFFF" size="4"> Onderwerp / Subject</font></p>
            <p>&nbsp;</p></td> 
            <td><p>
              <input type="text" name="sub" size="40">
              </p>
            <p>&nbsp;</p></td> 
          </tr> 
          <tr> 
            <td width="205" height="100" class="Kleiner"><p><font color="#FFFFFF" size="4">Bericht / Message</font></p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            </td> 
            <td> <p>
              <textarea name="field" wrap="VIRTUAL" cols="55" rows="10"></textarea>
              </p>            
            </td> 
          </tr> 
           
          <tr> 
            <td width="205" height="62">&nbsp;</td> 
            <td> <div align="left"> 
                <p>
                  <input type="Submit" name="Submit" value="Verzenden / Submit">
                </p>
                <p>&nbsp;</p>
            </div></td> 
          </tr> 
        </table> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" height="90%"> 
          <tr> 
            <td>&nbsp;</td> 
          </tr> 
        </table> 
      </td> 
    </tr> 
  </table> 
</form> 
<?php 
} 
?>




--------------------------------------------------------------------------------
Chat met al je vrienden. Voeg ze nu allemaal toe aan Messenger!
Was This Post Helpful? 0
  • +
  • -

#4 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 1,005
  • Joined: 30-July 08

Re: PHP code for return button

Posted 05 August 2008 - 04:30 AM

Wrong
<?php  
echo "<a href=/"index.php/">Back to the homepage</a>";  
?>


Right
<?php
echo "<a href=\"index.php\">Back to the homepage</a>";
?>


This also works
<?php
echo "<a href='index.php'>Back to the homepage</a>";
?>

Was This Post Helpful? 0
  • +
  • -

#5 Moonbat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Re: PHP code for return button

Posted 05 August 2008 - 05:25 AM

Oh, woops, I got my slashes wrong :P
Was This Post Helpful? 0
  • +
  • -

#6 bazzdaciple  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-August 08

Re: PHP code for return button

Posted 05 August 2008 - 09:34 AM

wauw, thanks for all the help. you guys are great.
one more question: when I receive the email in my hotmail (after it has been forwarded by my webhost) I do not see the sender and subject. Hotmail therefore considers the mail as threat and I have to "unlock" the mail before I can read it.

What is wrong in my code that prevents the sender and subject info to be forwarded to me??
Was This Post Helpful? 0
  • +
  • -

#7 bazzdaciple  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 04-August 08

Re: PHP code for return button

Posted 06 August 2008 - 05:07 PM

please help! I'm in a time squueze here.
Was This Post Helpful? 0
  • +
  • -

#8 pertheusual  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 245
  • Joined: 26-January 08

Re: PHP code for return button

Posted 06 August 2008 - 06:20 PM

A couple things to note, though I'm not 100% sure if they are the problem.

On this line:
$subject = $sub;
you aren't actually setting $sub anywhere in the code you posted.

I don't think you should have the \n at the end of the line.
$header = "From: " . $uwemail;

Hope that helps.

Per
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1