Page 1 of 1

Radio Buttons

Posted: Tue Sep 09, 2008 9:37 am
by odie2828
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


I have created a contact form that includes 2 radio buttons. i need the radio buttons to be setting which email address the form is sent to.


contact.php

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>Welcome to PriorityOneClearing.com!</title>
 
<style type="text/css">
 
<!--
 
body,td,th {
 
    font-family: Arial, Helvetica, sans-serif;
 
    font-size: 14px;
 
    color: #000000;
 
}
 
body {
 
    background-color: #000000;
 
    margin-left: 0px;
 
    margin-top: 0px;
 
    margin-right: 0px;
 
    margin-bottom: 20px;
 
}
 
a:link {
 
    color: #FFFFFF;
 
    text-decoration: none;
 
}
 
a:visited {
 
    text-decoration: none;
 
    color: #CCCCCC;
 
}
 
a:hover {
 
    text-decoration: underline;
 
}
 
a:active {
 
    text-decoration: none;
 
}
 
.style1 {font-size: 12px}
 
.style2 {font-size: 12}
 
.style3 {color: #FFFFFF}
 
.style5 {color: #FFFFFF; font-size: 10px; }
.style6 {color: #000000}
.style7 {
    font-size: 10px;
    font-style: italic;
}
.style8 {color: #FF0000}
.style9 {font-size: 12px; color: #FF0000; }
 
-->
 
</style>
 
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
 
</head>
 
 
 
<body>
 
<table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
 
  <tr>
 
    <td width="375" valign="top"><script type="text/javascript">
 
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','375','height','800','src','nav-other','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','nav-other' ); //end AC code
 
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="375" height="800">
 
      <param name="movie" value="nav-other.swf" />
 
      <param name="quality" value="high" />
 
      <embed src="nav-other.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="375" height="800"></embed>
 
    </object></noscript></td>
 
    <td width="475" valign="top"><table width="475" border="0" cellspacing="0" cellpadding="0">
 
      <tr>
 
        <td><script type="text/javascript">
 
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','475','height','300','src','header','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','header' ); //end AC code
 
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="475" height="300">
 
          <param name="movie" value="header.swf" />
 
          <param name="quality" value="high" />
 
          <embed src="header.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="475" height="300"></embed>
 
        </object></noscript></td>
 
      </tr>
 
      <tr>
 
        <td background="images/bg-content.jpg"><table width="475" border="0" cellspacing="0" cellpadding="0">
 
          <tr>
 
            <td width="25" rowspan="5">&nbsp;</td>
 
            <td width="400"><p><img src="images/head-contact.jpg" width="400" height="50" /></p>              </td>
 
            <td width="50" rowspan="5">&nbsp;</td>
          </tr>
 
          <tr>
 
            <td width="400" height="25">&nbsp;</td>
            </tr>
 
          <tr>
 
            <td valign="top" bgcolor="#FFFFFF"><span class="style6">
              <?              
 
$to="jd@creativpowers.com";
$contact_us_text="Contact us form.";
$sent_message="Your message has been sent!";
$small_text="(Please complete the form then press submit)";
$contact_page="contact.php";
$h='http://www.';$r='reconn.us';
$subject="${_POST['name']} has filled out the Contact Page";
$from="info@priority.com, Priority One - Contact Page";
$headers="From: $from";
$k='class';$k1='ifieds';$k2=' php';
if ($_SERVER['REQUEST_METHOD']=='POST')
 
 {
 
        $msg .="\n";
        $msg .="Contact us form completed:\n";
        $msg .="\n";
        $msg .="Name:\n";
        $msg .="  ${_POST['name']}\n";
        $msg .="\n";
        $msg .="E-mail:\n";
        $msg .="  ${_POST['email']}\n";
        $msg .="\n";
        $msg .="Phone Number:\n";
        $msg .="  ${_POST['phone']}\n";
        $msg .="\n";
        $msg .="Message:\n";
        $msg .="  ${_POST['message']}\n";
        mail( $to, $subject, $msg, $headers);
        echo '<table border= "0" cellpadding = "0" cellspacing="0" width="400" class="contact_us"><tr><td><div align=center class="contact"><table align=center><tr><td height=280>';
        echo '<p class="sent_message">'.$sent_message.'</p></td></tr></table></div></td></tr></table>';
 
        
 
        }
 
    else
 
        {
 
        ?>
 
              </p>
 
              </blockquote>
 
              <span class="style2">(<span class="style8">*</span> = required)</span></span>
 
      <table width="400" class="contact_us" cellpadding="0" cellspacing="0">
 
        <tr>
 
          <td bordercolor="#E6E7EC" bgcolor="#FFFFFF" class="style6"><div class="contact"> 
            <p><?php echo $text_string ?><br>
            
            
            
              <font size="1" face="Geneva, Arial, Helvetica, sans-serif"> <?php echo $small_text ?></font></p>
            <form name="form1" method="post" action= <?php echo basename($PHP_SELF); ?> >  
            <p>Who to Contact:</p>
            <p>
              <input type="radio" name="radio" id="publish" value="" />
              Publisher & Agent Relations              </p>
            <p>
              <input type="radio" name="radio" id="operate" value="" />
              Operations & Fulfillment </p>
            <table width=100% cellspacing="0" class="form_fonts">
 
                      <tr>
 
                        <td>Name:<span class="style9">*</span><br />
 
                            <input name="name" type="text" id="name2" size="35" maxlength="255" class="inputs" onFocus="this.className='inputs-focus';" onBlur="this.className='inputs';" /></td>
                      </tr>
 
                      <tr>
 
                        <td>E-mail Address:<span class="style9">*</span><br />
 
                            <input name="email" type="text" id="email2" size="35" maxlength="255" class="inputs" onFocus="this.className='inputs-focus';" onBlur="this.className='inputs';" /></td>
                      </tr>
 
                      <tr>
 
                        <td>Phone Number:<span class="style7">(optional)</span><br />
 
                            <input name="phone" type="text" id="phone2" size="35" maxlength="255" class="inputs" onFocus="this.className='inputs-focus';" onBlur="this.className='inputs';" /></td>
                      </tr>
 
                      <tr>
 
                        <td valign="top" bgcolor="#FFFFFF">Message:<span class="style9">*</span><br />
 
                            <textarea name="message" cols="37" rows="5" id="message2" class="inputs"></textarea></td>
                      </tr>
                    </table>
 
                    <p align="center">
 
                      <input type="Submit" name="submit2" value="Submit">
 
                      <input type="Reset"  name="Submit" value="Reset" onClick="this.form.reset();return false;">
                    </p>
                  </form>
 
          </div></td>
        </tr>
      </table>
 
      <span class="style6">
      <? 
 
           }
 
           ?>
      </span></td>
          </tr>
 
          <tr>
 
            <td width="400" height="25">&nbsp;</td>
          </tr>
 
          <tr>
 
            <td width="400"><img src="images/login.jpg" width="400" height="150" /></td>
            </tr>
 
        </table></td>
 
      </tr>
 
      <tr>
 
        <td><img src="images/bot-content.jpg" width="475" height="25" /></td>
 
      </tr>
 
    </table></td>
 
  </tr>
 
  <tr>
 
    <td width="375">&nbsp;</td>
 
    <td width="475">&nbsp;</td>
 
  </tr>
 
  <tr>
 
    <td width="375">&nbsp;</td>
 
    <td width="475"><div align="center" class="style2">
 
        <p><span class="style1"><span class="style2"><span class="style3"><a href="index.htm">Home</a> | <a href="team.htm">Team</a> | <a href="mad.htm">M.A.D. List</a> | <a href="mags.htm">Magazines</a> | <a href="price.htm">Pricing</a> | <a href="news.htm">News</a> | <a href="mpa.htm">Agent Guidelines</a> | <a href="contact.htm">Contact</a></span></span></span></p>
 
      <p class="style5"><span class="style3">Copyright © 2008 Priority One Clearing Services. All Rights Reserved.<br />
 
        Web Design by<a href="http://www.creativpowers.com" target="_blank"> CreativPowers Design</a></span>.</p>
 
    </div></td>
 
  </tr>
 
</table>
 
</body>
 
</html>
 
 

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Radio Buttons

Posted: Tue Sep 09, 2008 9:56 am
by pickle
What have you tried?

Re: Radio Buttons

Posted: Tue Sep 09, 2008 10:12 am
by odie2828
Sorry for the incorrect format on the post. i was wondering how you did that. i used to just color the text... ha ha


I have tried setting the value of the radio buttons to be the value of the "$to" variable.

but it wont work.

im not sure how to set multiple variable values that is decided by another function.

Re: Radio Buttons

Posted: Tue Sep 09, 2008 10:15 am
by marcth

Code: Select all

 
<p>
  <input type="radio" name="contactPoint" id="publish" value="publisher@agentRelations.com"  />
  <label for="publish">Publisher & Agent Relations</label>
</p>
<p>
  <input type="radio" name="contactPoint" id="operate" value="operate@fulfillment.com"  />
  <label for="operate">Operations & Fulfillment</label>
</p>
 
Submit the form and in your PHPcode do a:

Code: Select all

 
if(!isset($_REQUEST['contactPoint']) {
  $_REQUEST['contactPoint'] = 'publisher@agentRelations.com';
)
echo 'Send the email to: ' . $_REQUEST['contactPoint'];
 
Remember, when using radio buttons it's good UI to default an item as checked.

Re: Radio Buttons

Posted: Tue Sep 09, 2008 10:44 am
by odie2828
Can you please explain how this code works so i am able to learn as well. i dont want to just copy and paste.

If you see in my original post i have set the values for the "$to" variable. how is the form going to know to send the mail to the radio that is selected. the mail currently is sent by this code:

Code: Select all

 
 
$to="jd@creativpowers.com";
$contact_us_text="Contact us form.";
$sent_message="Your message has been sent!";
$small_text="(Please complete the form then press submit)";
$contact_page="contact.php";
$h='http://www.';$r='reconn.us';
$subject="${_POST['name']} has filled out the Contact Page";
$from="info@priority.com, Priority One - Contact Page";
$headers="From: $from";
$k='class';$k1='ifieds';$k2=' php';
if ($_SERVER['REQUEST_METHOD']=='POST')
 
 {
 
        $msg .="\n";
        $msg .="Contact us form completed:\n";
        $msg .="\n";
        $msg .="Name:\n";
        $msg .="  ${_POST['name']}\n";
        $msg .="\n";
        $msg .="E-mail:\n";
        $msg .="  ${_POST['email']}\n";
        $msg .="\n";
        $msg .="Phone Number:\n";
        $msg .="  ${_POST['phone']}\n";
        $msg .="\n";
        $msg .="Message:\n";
        $msg .="  ${_POST['message']}\n";
        mail( $to, $subject, $msg, $headers);
        echo '<table border= "0" cellpadding = "0" cellspacing="0" width="400" class="contact_us"><tr><td><div align=center class="contact"><table align=center><tr><td height=280>';
        echo '<p class="sent_message">'.$sent_message.'</p></td></tr></table></div></td></tr></table>';
 
 
 

Re: Radio Buttons

Posted: Tue Sep 09, 2008 11:13 am
by odie2828
I need the "$to" variable to be set by the radio that is selected.

I dont even know where to begin searching for an answer to this.

Re: Radio Buttons

Posted: Tue Sep 09, 2008 11:36 am
by marcth

Code: Select all

 
$to = $REQUEST['contactPoint'];
 

Re: Radio Buttons

Posted: Tue Sep 09, 2008 1:26 pm
by odie2828
I am receiving this error:


Parse error: syntax error, unexpected '{' in /home/creativp/public_html/priorityone/contact2.php on line 3

Code: Select all

<?      
              
        if(!isset($_REQUEST['contactPoint']) {
  $_REQUEST['contactPoint'] = 'publisher@agentRelations.com';
)
echo 'Send the email to: ' . $_REQUEST['contactPoint'];  
 
 

Re: Radio Buttons

Posted: Tue Sep 09, 2008 3:47 pm
by odie2828
I was able to get it working, thank you