Jump to content

Recommended Posts

hello, this is part of my contact form code.

When i click on the submit button i need the form to take me to the $success_message or the $failure_message instead of the top of the page.

I know i can do it with # tag or # id normally.

But I do not know how to apply it to the form.

 

 

//some text and stuff<tr>
   <td>
   <? if(!empty($success_message))
      {
        echo "<center><font color='blue'><b>".$success_message."</b></font><br></p>";
      }
      if(!empty($failure_message))
      {
         echo "<center><font color='red'><b>".$failure_message."</b></font><br></p>";
      }
   ?>

<?
if((empty($_POST)) || !empty($strError))
{
     echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>";
?>


  <form action="<?php echo $PHP_SELF;?>" method="post">
      <tr height='40'>
         <td>
           <font color="black"><B> First Name: </B></font>
         </td>
 <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" class="advertising-inputbox-style" />
            <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?>
 </td>

      </tr>
      <tr height='40'>
     <td><font color="black"><B> Last Name: </B></font></td>
     <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>" class="advertising-inputbox-style"/>
     <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?>
             </td>
      </tr>

      <tr height='40'>
     <td><font color="black"><B> Email Address: </B></font></td>
     <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>" class="advertising-inputbox-style"/>
     <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?>
             </td>
      </tr>
       <tr height='35'>
	     <td><font color="black"><B> Business Name: </B></font></td>
	     <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" class="advertising-inputbox-style" />
      <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?>
             </td>
      </tr>

      <tr>
         <td><font color="black"><B> Business Description: </B></font></td>
         <td ><textarea rows=7 cols=31 name="description" class="advertising-textarea-style"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea>
         <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?>
         </td>


      <tr height='35'>
         <td></td>
         <td><input type="submit" name="submit" value="submit" /></td>
      </tr>

   </form>

Link to comment
https://forums.phpfreaks.com/topic/253118-take-browser-to-the-message/
Share on other sites

i tried something like this, but i am not sure of the syntax..

 <? if(!empty($success_message))
      {
        echo "<p class='#form'><center><font color='blue'><b>".$success_message."</b></font><br></p>";
      }
      if(!empty($failure_message))
      {
         echo "<p class='#form'><center><font color='red'><b>".$failure_message."</b></font><br></p>";
      }
   ?>

<?
if((empty($_POST)) || !empty($strError))
{
     echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>";
?>
<tr>
  <td>

   <form action="<?php echo $PHP_SELF;?>" method="post" class="#form">

//some text and stuff<tr>
   <td name="msg">
   <? if(!empty($success_message))
      {
        echo "<center><font color='blue'><b>".$success_message."</b></font><br></p>";
      }
      if(!empty($failure_message))
      {
         echo "<center><font color='red'><b>".$failure_message."</b></font><br></p>";
      }
   ?>

<?
if((empty($_POST)) || !empty($strError))
{
     echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>";
?>


  <form action="<?php echo $PHP_SELF;?>#msg" method="post">
      <tr height='40'>
         <td>
           <font color="black"><B> First Name: </B></font>
         </td>
    <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" class="advertising-inputbox-style" />
            <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?>
    </td>

      </tr>
      <tr height='40'>
        <td><font color="black"><B> Last Name: </B></font></td>
        <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>" class="advertising-inputbox-style"/>
        <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?>
             </td>
      </tr>

      <tr height='40'>
        <td><font color="black"><B> Email Address: </B></font></td>
        <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>" class="advertising-inputbox-style"/>
        <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?>
             </td>
      </tr>
       <tr height='35'>
         <td><font color="black"><B> Business Name: </B></font></td>
         <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" class="advertising-inputbox-style" />
         <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?>
             </td>
      </tr>

      <tr>
         <td><font color="black"><B> Business Description: </B></font></td>
         <td ><textarea rows=7 cols=31 name="description" class="advertising-textarea-style"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea>
         <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?>
         </td>


      <tr height='35'>
         <td></td>
         <td><input type="submit" name="submit" value="submit" /></td>
      </tr>

   </form>

:confused:

You want to specify the 'fragment identifier' in your HTML form's action

<form action="process.php#message" method="post">

 

And on process.php

 

<span id="message">Your message here</form>

 

This is all HTML, and not PHP. Generally, if it's client-side behavior, it doesn't belong in this forum.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.