logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-22-2011, 02:10 AM   #1
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default contact form to db error.

Guys, I have not worked with php in a while and it shows. I have a problem I have not been able to find a solution. I am trying to push info into a database but, for some reason I can't get the info picked from the radio buttons to post. Can someone look to see what I'm doing wrong please? Ty. Here are the codes:

Code:
<form id="form1" name="form1" method="post" action="">
      <table width="886" border="0">
        <tr>
          <td width="566" align="right" class="options"><div align="right"><span class="title">Please tell us about yourself:</span></div></td>
          <td width="310">&nbsp; </td>
        </tr>
        <tr>
          <td align="right">*Full Name:</td>
          <td><label>
            <input name="name" type="text" class="fields" id="name" />
          </label></td>
        </tr>
        <tr>
          <td align="right">*Title:</td>
          <td><label for="title"></label>
            <select name="title" id="title">
              <option>Pick one</option>
              <option>Owner</option>
              <option>Mgr</option>
              <option>Promoter</option>
              <option>Other</option>
          </select></td>
        </tr>
        <tr>
          <td align="right">*E-mail:</td>
          <td><label for="email"></label>
          <input type="text" name="email" id="email" /></td>
        </tr>
        <tr>
          <td align="right">*Tel #:</td>
          <td><label for="telephone"></label>
          <input type="text" name="telephone" id="telephone" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right" class="title">Please tell us about your venue:</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td align="right">*Name:</td>
          <td><label for="venue_name"></label>
          <input type="text" name="venue_name" id="venue_name" /></td>
        </tr>
        <tr>
          <td height="27" align="right" valign="top">*State located:</td>
          <td valign="top"><label for="state_located"></label>
            <select name="state_located" id="state_located">
              <option value="AL">Alabama</option>
              <option value="AK">Alaska</option>
              <option value="AZ">Arizona</option>
              <option value="AR">Arkansas</option>
              <option value="CA">California</option>
              <option value="CO">Colorado</option>
              <option value="CT">Connecticut</option>
              <option value="DE">Delaware</option>
              <option value="DC">District of Columbia</option>
              <option value="FL">Florida</option>
              <option value="GA">Georgia</option>
              <option value="HI">Hawaii</option>
              <option value="ID">Idaho</option>
              <option value="IL">Illinois</option>
              <option value="IN">Indiana</option>
              <option value="IA">Iowa</option>
              <option value="KS">Kansas</option>
              <option value="KY">Kentucky</option>
              <option value="LA">Louisiana</option>
              <option value="ME">Maine</option>
              <option value="MD">Maryland</option>
              <option value="MA">Massachusetts</option>
              <option value="MI">Michigan</option>
              <option value="MN">Minnesota</option>
              <option value="MS">Mississippi</option>
              <option value="MO">Missouri</option>
              <option value="MT">Montana</option>
              <option value="NE">Nebraska</option>
              <option value="NV">Nevada</option>
              <option value="NH">New Hampshire</option>
              <option value="NJ">New Jersey</option>
              <option value="NM">New Mexico</option>
              <option value="NY">New York</option>
              <option value="NC">North Carolina</option>
              <option value="ND">North Dakota</option>
              <option value="OH">Ohio</option>
              <option value="OK">Oklahoma</option>
              <option value="OR">Oregon</option>
              <option value="PA">Pennsylvania</option>
              <option value="RI">Rhode Island</option>
              <option value="SC">South Carolina</option>
              <option value="SD">South Dakota</option>
              <option value="TN">Tennessee</option>
              <option value="TX">Texas</option>
              <option value="UT">Utah</option>
              <option value="VT">Vermont</option>
              <option value="VA">Virginia</option>
              <option value="WA">Washington</option>
              <option value="WV">West Virginia</option>
              <option value="WI">Wisconsin</option>
              <option value="WY">Wyoming</option>
          </select></td>
        </tr>
        <tr>
          <td height="42" align="right" valign="top">Do you have more than one venue:</td>
          <td valign="top"><p>
            <label> </label>
            <label>
              <input type="radio" name="venues" value="yes" id="venues_0" />
              Yes</label>
           
            <label>
              <input type="radio" name="venues" value="no" id="venues_1" />
              No</label>
            
          </p></td>
        </tr>
        <tr>
          <td height="27" align="right" valign="top">*Type of venue:</td>
          <td valign="top"><p>
            <label> </label>
            <label for="type_venue"></label>
            <select name="type_venue" id="type_venue">
              <option>Pick one</option>
              <option>Night club</option>
              <option>Restaurant</option>
              <option>Comedy club</option>
              <option>Other</option>
            </select>
            <br />
          </p></td>
        </tr>
        <tr>
          <td height="29" align="right" valign="top">If you're not a promoter, does the venue use the services of a promoter?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="promoter" value="yes" id="promoter_0" />
              Yes</label>
           
            <label>
              <input type="radio" name="promoter" value="no" id="promoter_1" />
              No</label>
            
          </p></td>
        </tr>
        <tr>
          <td height="25" align="right" valign="top">Does the venue currently have a reservation system?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="reservation" value="yes" id="reservation_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="reservation" value="no" id="reservation_1" />
              No</label>
            <br />
          </p></td>
        </tr>
        <tr>
          <td height="27" align="right" valign="top">If yes, what service?</td>
          <td valign="top"><label for="service"></label>
          <input type="text" name="service" id="service" /></td>
        </tr>
        <tr>
          <td height="41" align="right" valign="top">Does the venue currently have a table reservation system?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="table_reservation" value="Yes" id="table_reservation_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="table_reservation" value="No" id="table_reservation_1" />
              No</label>
            <br />
           
          </p></td>
        </tr>
        <tr>
          <td height="27" align="right" valign="top">Would you be interested in improving your cash flow by collecting admission prior to an event or opening night?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="cash_flow" value="Yes" id="cash_flow_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="cash_flow" value="No" id="cash_flow_1" />
              No</label>
           
          </p></td>
        </tr>
        <tr>
          <td height="24" align="right" valign="top">Does the venue offer special VIP cards?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="vip_cards" value="Yes" id="vip_cards_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="vip_cards" value="No" id="vip_cards_1" />
              No</label>
           
          </p></td>
        </tr>
        <tr>
          <td height="21" align="right" valign="top">Would you use an automated reservation system?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="automated" value="Yes" id="automated_0" />
              Yes</label>
            <br />
            <label>
              <input type="radio" name="automated" value="No" id="automated_1" />
              No</label>
           <br />
          </p></td>
        </tr>
        <tr>
          <td height="25" align="right" valign="top">Would you use an automated table reservation sytem?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="table_reserve" value="Yes" id="table_reserve_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="table_reserve" value="No" id="table_reserve_1" />
              NO</label>
           
          </p></td>
        </tr>
        <tr>
          <td height="24" align="right" valign="top">Does your marketing department use an E-mail markeitng service?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="email_marketing" value="Yes" id="email_marketing_0" />
              Yes</label>
           
            <label>
              <input type="radio" name="email_marketing" value="No" id="email_marketing_1" />
              No</label>
            
          </p></td>
        </tr>
        <tr>
          <td height="24" align="right" valign="top">*If yes, which one?</td>
          <td valign="top"><label for="email_service"></label>
            <select name="email_service" id="email_service">
              <option>Pick one</option>
              <option>Constant Contact</option>
              <option>Mail Chimp</option>
              <option>G-mail</option>
              <option>Outlook</option>
              <option>Other</option>
          </select></td>
        </tr>
        <tr>
          <td height="14" align="right" valign="top">Would  you use an automated system to manage multiple venues, improve your cash flow, RSVP,  admissions and table reservations as well as e-mail/sms marketing, all in one interface? ?</td>
          <td valign="top"><p>
            <label> </label>
            <label> </label>
            <label>
              <input type="radio" name="interface" value="Yes" id="interface_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="interface" value="No" id="interface_1" />
              No</label>
            
          </p></td>
        </tr>
        <tr>
          <td height="6" align="right" valign="top">If yes, would you include this service in all your marketing materials?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="marketing" value="Yes" id="marketing_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="marketing" value="No" id="marketing_1" />
              No</label>
            
          </p></td>
        </tr>
        <tr>
          <td height="2" align="right" valign="top">How much would you pay for this system?</td>
          <td valign="top"><label for="pay"></label>
          <input type="text" name="pay" id="pay" /></td>
        </tr>
        <tr>
          <td height="0" align="right" valign="top">Do you liike the name Xtallion?</td>
          <td valign="top"><p>
            <label>
              <input type="radio" name="xtallion" value="Yes" id="xtallion_0" />
              Yes</label>
            
            <label>
              <input type="radio" name="xtallion" value="No" id="xtallion_1" />
              No</label>
           
          </p></td>
        </tr>
        <tr>
          <td height="2" align="right" valign="top">If no, what would you call it?</td>
          <td valign="top"><label for="app_name"></label>
          <input type="text" name="app_name" id="app_name" /></td>
        </tr>
        <tr>
          <td height="27" align="right" valign="top">Give us your feedback:</td>
          <td valign="top"><label>
            <textarea name="feedback" cols="45" rows="5" class="fields" id="feedback"></textarea>
          </label></td>
        </tr>
        <tr>
          
        </tr>
        <tr>
          <td height="57" align="right" valign="top"><p>
            <input type="submit" name="submit" id="submit" value="Submit" />            
            <input type="reset" name="Reset" id="Reset" value="Reset" />
          </p>
          <p>&nbsp;</p></td>
          <td valign="top">&nbsp;</td>
        </tr>
      </table>
    </form>
PHP Code:
<?php
$con 
mysql_connect("0000","oooo","oooo"); //Replace with your actual MySQL DB Username and Password
if (!$con

die(
'Could not connect: ' mysql_error()); 

mysql_select_db("ilouie_xtallionsurvey"$con); //Replace with your MySQL DB Name

$name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
$title=mysql_real_escape_string($_POST['title']);
$email=mysql_real_escape_string($_POST['email']);
$telephone=mysql_real_escape_string($_POST['telephone']);
$venue_name=mysql_real_escape_string($_POST['venue_name']);
$state_located=mysql_real_escape_string($_POST['state_located']);
$venues=mysql_real_escape_string($_POST['venues_0']);
$venues=mysql_real_escape_string($_POST['venues_1']); //This value has to be the same as in the HTML form file
$type_venue=mysql_real_escape_string($_POST['type_venue']); 
$promoter=mysql_real_escape_string($_POST['promoter_0']); 
$promoter=mysql_real_escape_string($_POST['promoter_1']); 
$reservation=mysql_real_escape_string($_POST['reservation_0']); 
$reservation=mysql_real_escape_string($_POST['reservation_1']); 
$service=mysql_real_escape_string($_POST['service']); 
$table_reservation=mysql_real_escape_string($_POST['table_reservation_0']); 
$table_reservation=mysql_real_escape_string($_POST['table_reservation_1']); 
$cash_flow=mysql_real_escape_string($_POST['cash_flow_0']);
$cash_flow=mysql_real_escape_string($_POST['cash_flow_1']);
$vip_cards=mysql_real_escape_string($_POST['vip_cards_0']);
$vip_cards=mysql_real_escape_string($_POST['vip_cards_1']);
$automated=mysql_real_escape_string($_POST['automated_0']);
$automated=mysql_real_escape_string($_POST['automated_1']);
$table_reserve=mysql_real_escape_string($_POST['table_reserve_0']);
$table_reserve=mysql_real_escape_string($_POST['table_reserve_1']);
$email_marketing=mysql_real_escape_string($_POST['email_marketing_0']);
$email_marketing=mysql_real_escape_string($_POST['email_marketing_1']);
$email_service=mysql_real_escape_string($_POST['email_service_0']);
$email_service=mysql_real_escape_string($_POST['email_service_1']);
$interface=mysql_real_escape_string($_POST['interface_0']);
$interface=mysql_real_escape_string($_POST['interface_1']);
$marketing=mysql_real_escape_string($_POST['marketing_0']);
$pay=mysql_real_escape_string($_POST['pay']);
$xtallion=mysql_real_escape_string($_POST['xtallion_0']);
$xtallion=mysql_real_escape_string($_POST['xtallion_1']);
$app_name=mysql_real_escape_string($_POST['app_name']);
$feedback=mysql_real_escape_string($_POST['feedback']);




$sql="INSERT INTO atrium (name,title,email,telephone,venue_name,state_located,venues_0,venues_1,type_venue,promoter_0,promoter_1,reservation_0,reservation_1,service,table_reservation_0,table_reservation_1,cash_flow_0,cash_flow_1,vip_cards_0,vip_cards_1,automated_0,automated_1,table_reserve_0,table_reserve_1,email_marketing_0,email_marketing_1,email_service,interface_0,interface_1,marketing_0,marketing_1,pay,xtallion_0,xtallion_1,app_name,feedback)



VALUES ('
$name','$title','$email','$telephone','$venue_name','$state_located','$venues_0','$venues_1','$type_venue','$promoter_0','$promoter_1','$reservation_0','$reservation_1','$service','$table_reservation_0','$table_reservation_1','$cash_flow_0','$cash_flow_1','$vip_cards_0','$vip_cards_1','$automated_0','$automated_1','$table_reserve_0','$table_reserve_1','$email_marketing_0','$email_marketing_1','$email_service','$interface_0','$interface_1','$marketing_0','$marketing_1','$pay','$xtallion_0','$xtallion_1','$app_name','$feedback')"/*form_data is the name of the MySQL table where the form data will be saved.

name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
 die(
'Error: ' mysql_error()); 

echo 
"thank you"
mysql_close($con);
?>
Thanks in advance..
__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Old 12-22-2011, 06:09 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,162
Default

i am too strapped for time but looking quickly you are looking at an either or with the radio buttons so the value will be passed simply as for example
$_POST['promoter'] dont name them 1 and 2 as only one value will be passed. that should get you right
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-22-2011, 11:11 AM   #3
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default

Thanks E..That did it.. Originally I had set up the the sending file as checkboxes and then I went to the radio..
__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Old 12-22-2011, 01:19 PM   #4
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default

E, I have another question. maybe you can find a solution. Besides the database script, I also have as a "php include" a script to send info to an e-mail. The scripts are working fine but, I'm trying to validate them with this

Code:
function is_valid_name($name) {
  return ( $name);
}

if (!is_valid_name($name)) {
  echo 'Sorry, you must enter your name. Please go back and enter your name.';
  exit;
}
and since I'm only including it on the db script, the information goes right through to the e-mail script without validating. I tried including above code on both scripts but then I get a server error saying that I can't include code on both scripts. Any idea how to get around it. I don't really want to use a captcha unless I have too...Thanks..
__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Old 12-22-2011, 05:56 PM   #5
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default

Anybody else would have a solution? Ty
__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Old 12-23-2011, 12:10 AM   #6
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,162
Default

try adding once after you declare the vars . that should stop the script
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-23-2011, 12:53 AM   #7
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default

I swear there's a little monster inside this computer. What you've suggested I tried all day. All of the sudden is working. Lol...Thanks...
__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Old 12-23-2011, 01:02 AM   #8
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default

Another question...I haven't done this in a while..Trying to validate telephone number abut it'll keep asking to validate..any idea? Thanks again..
PHP Code:
function is_valid_telephone($telephone) {

  
$value = array('###-###-####',

        
'(###)###-####',

        
'##########','###.###.####',

        
'(###) ###-####');

  
$value trim(preg_replace("/[0-9]/","#",$telephone));

  

  }if (!
is_valid_telephone($telephone)) {
  echo 
'Sorry, you must enter your number';
  exit;

__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Old 12-23-2011, 02:21 AM   #9
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,162
Default

i can give you a link or 2 problems usually come from format of the number, as a thought you could ask country code, area code then number and concat the field, just an idea

any hoo http://stackoverflow.com/questions/3...mber-using-php

http://plasticbrain.net/resources/ph...-phone-number/
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-23-2011, 08:00 PM   #10
gigiloumill
gigiloumill's Avatar
 
Join Date: Apr 2009
Location: Miami, FL
Posts: 493
Default

ty..Merry Christmas...
__________________
Keeping your business connected.
www.starionmedia.com
gigiloumill is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com