473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Need help with scripting to store data on MySQL

mideastgirl
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a different issue than what I was initially having.
I am working on storing data collected from a form on my website. I would like the information to be stored into MySQL once entered by users. I have googled this question and have tried multiple suggestions and have progressed slightly. The problem that I am having is that the page after I press the submit button (actually called Add Member) comes up blank. I would like the page to either read "Thank you, your information has been added" or "Error-incomplete information provided, please fill out the form" or something along those lines.

So my problem is getting the information to store to MySQL and then getting the filled out form page to move onto the next page.

Please see: http://mideasthonors.org/addmember.php to view the form.

This is the scripting I have for the form information to be added to MySQL:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ("admintasks-dbcon.php");
  3. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  4. mysql_select_db($dbname);
  5.  
  6. $query = 'SELECT * FROM $add_member';
  7. $result = mysql_query($query);
  8.  
  9. if($result) 
  10.  {
  11.      while($row = mysql_fetch_array($result))
  12.      {
  13.          $name = $row['$yourfield'];
  14.          echo 'Name: '.$name;
  15.  
  16.          mysql_select_db("mideasthonors");
  17.  
  18.          $sql="INSERT INTO $add_member (Name, Address 1, Address 2, City, State, Zip Code, Website, Contact Name, Position, Phone Number, Email Address) 
  19.          VALUES {$_POST['name']},{$_POST['address 1']},{$_POST['address 2']},{$_POST['city']},{$_POST['state']},{$_POST['zip code']},{$_POST['website']},{$_POST['contact name']},{$_POST['position']},{$_POST['phone number']},{$_POST['email address']})";
  20.  
  21.          if (!mysql_query($sql,$con))         
  22.          {
  23.              die('Error: ' . mysql_error());
  24.          }
  25.  
  26.         echo 'Thank You! Your information has been entered into the database!'; 
  27.      }
  28.  } 
  29. ?>
  30.  
This is the error page I have set up:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4. <head>
  5. <meta http-equiv="Content-Language" content="en-us" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>Error</title>
  8. <style type="text/css">
  9. .style1 {
  10.     font-family: Arial, Helvetica, sans-serif;
  11.     font-size: medium;
  12. }
  13.  
  14. .style29 {
  15.     font-family: Arial, Helvetica, sans-serif;
  16. }
  17. h2 {
  18.     font-family: Verdana, Arial, Helvetica, sans-serif;
  19.     font-size: 17px;
  20.     font-weight: bold;
  21.     color: #2F77F1;
  22.     line-height: 20px;
  23. }
  24. .style30 {
  25.     font-family: geneva, arial;
  26.     font-size: 10pt;
  27. }
  28.  
  29. .style31 {
  30.     font-family: Verdana, Arial, Helvetica, sans-serif;
  31.     font-size: 12px;
  32.     line-height: 11pt;
  33.     margin: 3px 0;
  34.     padding-bottom: 9px;
  35. }
  36. </style>
  37. </head>
  38.  
  39. <body>
  40.  
  41. <p class="style1"><strong>Error: All fields have not been filled in, or information is inaccurate. Please complete form.</strong></p>
  42. <form method="post" action="addmember.php" style="width: 169px">
  43. *
  44.  
  45.     <table>
  46.  
  47.         <tr>
  48.             <td colspan=2><h2 class="style29">Institution Information</h2></td>
  49.         </tr>
  50.  
  51.         <tr>
  52.             <td class='style30'><p class="style31"><label for='name'>Name*</label></p></td>
  53.             <td class="style30"><input type='text' name='name' size=45 maxlength=100 /></td>
  54.         </tr>
  55.  
  56.         <tr>
  57.             <td class='style30'><p class="style31"><label for='address_1'>Address*</label></p></td>
  58.             <td class="style30"><input type='text' name='address_1' size=45 maxlength=100 /></td>
  59.         </tr>
  60.  
  61.         <tr>
  62.             <td class="style30">&nbsp;</td>
  63.             <td class="style30"><input type='text' name='address_2' size=45 maxlength=100 /></td>
  64.         </tr>
  65.  
  66.         <tr>
  67.             <td class='style30'><p class="style31"><label for='city'>City*</label></p></td>
  68.             <td class="style30"><input type='text' name='city' size=45 maxlength=50 /></td>
  69.         </tr>
  70.  
  71.         <tr>
  72.             <td class='style30'><p class="style31"><label for='state'>State*</label>
  73.             <td class="style30">
  74.                 <select name='state'>
  75.                 <?php
  76.                 $states = array("Illinois", "Indiana", "Kentucky", "Michigan", "Ohio", "Pennsylvania", "Tennessee", "West Viriginia");
  77.                 foreach($states as $a => $value){
  78.                     echo "<option name='$value'>$value</option>";
  79.                 }
  80.                 ?>
  81.                 </select>
  82.             </td>
  83.         </tr>
  84.  
  85.         <tr>
  86.             <td class='style30'><p class="style31"><label for='zip'>ZIP Code*</label></p></td>
  87.             <td class="style30"><input type='text' name='zip' size=10 maxlength=10 /></td>
  88.         </tr>
  89.  
  90.         <tr>
  91.             <td class='style30'><p class="style31"><label for='website'>Website*</label></p></td>
  92.             <td class="style30"><input type='text' name='website' value='http://www.' size=45 maxlength=100 /></td>
  93.         </tr>
  94.  
  95.         <tr>
  96.             <td colspan=2><h2 class="style29">Contact Information</h2></td>
  97.         </tr>
  98.  
  99.         <tr>
  100.             <td class='style30'><p class="style31"><label for='contact_name'>Contact Name*</label></p></td>
  101.             <td class="style30"><input type='text' name='contact_name' size=45 maxlength=100 /></td>
  102.         </tr>
  103.  
  104.         <tr>
  105.             <td class='style30'><p class="style31"><label for='contact_position'>Position</label></p></td>
  106.             <td class="style30"><input type='text' name='contact_position' size=45 maxlength=100 /></td>
  107.         </tr>
  108.  
  109.         <tr>
  110.             <td class='style30'><p class="style31"><label for='contact_phone'>Phone Number*</label></p></td>
  111.             <td class="style30"><input type='text' name='contact_phone' size=14 maxlength=14 /></td>
  112.         </tr>
  113.  
  114.         <tr>
  115.             <td class='style30'><p class="style31"><label for='contact_email'>Email Address*</label></p></td>
  116.             <td class="style30"><input type='text' name='contact_email' size=45 maxlength=100 /></td>
  117.         </tr>
  118.  
  119.         <tr>
  120.             <td class="style30">&nbsp;</td>
  121.             <td class="style30"><input type='submit' name ="Add Member" value='Add Member' /></td>
  122.         </tr>
  123.  
  124.     </table>
  125.  
  126.  
If anyone could help me out I would really appreciate it!
Jul 22 '09 #1
70 5271
Dormilich
8,658 Expert Mod 8TB
the script seems somewhat strange...
  • is $add_member really the MySQL field name? (single quotes ain't parsed)
  • same goes for $row['$yourfield'].
  • why do you need to insert the form values for every already existing member?
  • you need protection against SQL injection (at least use mysql_real_escape_string($_POST[$key])!)
you can forward to another page by
Expand|Select|Wrap|Line Numbers
  1. header('Location: _url_comes_here_');
  2. exit;
note: there must not be any output before that.
Jul 22 '09 #2
No add_member is the table name. I thought that was supposed to go there. Also, the table is not for existing members it is for new members.

Maybe I am confused about what needs to go where.

Thanks.
Jul 22 '09 #3
Atli
5,058 Expert 4TB
Hi.

The problem there is just with the basic syntax.

First, as Dormilich pointed out, while variables are parse within double-quoted strings, they are not parsed within single-quoted strings.
(See PHP: Strings - Manual)

Which means your query on line #6 is literally being sent as:
SELECT * FROM $add_member, whereas you probably meant for it to insert the value of $add_member.
If you want that to happen, you need to use double-quotes, rather than single-quotes.

And second:
The if statement on line #9, which checks the result of the SQL query, does not provide any code in case the check fails. Which means that every time the query fails, you are shown a blank page.
You should add an else clause, and print an error message or something, just so you don't get a useless blank page.
Jul 22 '09 #4
anfetienne
424 256MB
the 1st sql query is relevant if you want to check for duplicate entries. but i dont see why you have a while loop in the when you can check if using

if ( mysql_num_rows( $res ) > 0 )
{
UPDATE table
}

else{
INSERT INTO table
}

look at this example that i have of a form and the php to add it to sql (please excuse the length of the form there is alot of javascript for tinyMCE included in my form)

FORM CODE
Expand|Select|Wrap|Line Numbers
  1. <form id="form1" name="form1" method="POST" action="save.php">
  2.         <tr>
  3.         <td>  
  4.   <input type="hidden" name="rtrnURL" id="rtrnURL" value='<?php print $rtrnURL;?>'/>      
  5.   <input type="hidden" name="tempID" id="tempID" value='<?php print $random_digit;?>'/> 
  6.   <input type="hidden" name="htmlcss" id="htmlcss" value='<?php print $htmlcss;?>'/>      
  7.   <input type="hidden" name="header" id="header" value='<?php print $header;?>'/>
  8.   <input type="hidden" name="nav" id="nav" value='<?php print $nav;?>'/>      
  9.   <input type="hidden" name="titleWrap01" id="titleWrap01" value='<?php print $titleWrap01;?>'/> 
  10.   <input type="hidden" name="titleWrap02" id="titleWrap02" value='<?php print $titleWrap02;?>'/>      
  11.   <input type="hidden" name="subheadWrap01" id="subheadWrap01" value='<?php print $subheadWrap01;?>'/>
  12.   <input type="hidden" name="subheadWrap02" id="subheadWrap02" value='<?php print $subheadWrap02;?>'/>      
  13.   <input type="hidden" name="flashWrap01" id="flashWrap01" value='<?php print $flashWrap01;?>'/> 
  14.   <input type="hidden" name="flashWrap02" id="flashWrap02" value='<?php print $flashWrap02;?>'/>      
  15.   <input type="hidden" name="flash01" id="flash01" value='var so = new SWFObject("<?php print $flashURL;?>", "gallery", "518", "536", "8", "#FFFFFF");'/>
  16.   <input type="hidden" name="flashVar" id="flashVar" value='<?php print $flashVar;?>'/>      
  17.   <input type="hidden" name="flash02" id="flash02" value='<?php print $flash02;?>'/> 
  18.   <input type="hidden" name="flashWrap03" id="flashWrap03" value='<?php print $flashWrap03;?>'/>
  19.   <input type="hidden" name="descriptionWrap01" id="descriptionWrap01" value='<?php print $descriptionWrap01;?>'/>
  20.   <input type="hidden" name="descriptionWrap02" id="descriptionWrap02" value='<?php print $descriptionWrap02;?>'/>      
  21.   <input type="hidden" name="generalWrap01" id="generalWrap01" value='<?php print $generalWrap01;?>'/> 
  22.   <input type="hidden" name="generalWrap02" id="generalWrap02" value='<?php print $generalWrap02;?>'/>      
  23.   <input type="hidden" name="aboutWrap01" id="aboutWrap01" value='<?php print $aboutWrap01;?>'/>
  24.   <input type="hidden" name="aboutWrap02" id="aboutWrap02" value='<?php print $aboutWrap02;?>'/>      
  25.   <input type="hidden" name="paymentWrap01" id="paymentWrap01" value='<?php print $paymentWrap01;?>'/> 
  26.   <input type="hidden" name="paymentWrap02" id="paymentWrap02" value='<?php print $paymentWrap02;?>'/>
  27.   <input type="hidden" name="termsWrap01" id="termsWrap01" value='<?php print $termsWrap01;?>'/>      
  28.   <input type="hidden" name="termsWrap02" id="termsWrap02" value='<?php print $termsWrap02;?>'/>
  29.   <input type="hidden" name="footer" id="footer" value='<?php print $footer;?>'/> 
  30.   </td>
  31.       </tr>
  32.  
  33.     <table width="700" border="0" align="center" cellpadding="2" cellspacing="2">
  34.       <tr>
  35.           <p>
  36.           <center><input name="Submit2" type="submit" value="Save Template" />
  37.             <br />
  38.           </center>
  39.           </p>
  40.       </tr>
  41.       <tr>
  42.         <td>Title</td>
  43.         <td><input name="title"  type="text" value="<? print $row['title'];?>" size="75" maxlength="60" /></td>
  44.       </tr>
  45.       <tr>
  46.         <td>Subtitle</td>
  47.         <td><input name="subheading"  type="text" value="<? print $row['subheading'];?>" size="75" /></td>
  48.       </tr>
  49.       <tr>
  50.         <td>Description</td>
  51.             <script type="text/javascript">
  52.                             tinyMCE.init({
  53.                                 mode : "exact"
  54.                                 ,elements : "id_description"
  55.                                 ,theme : "advanced"
  56.                                 ,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
  57.                                 ,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
  58.                                 ,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
  59.                                 ,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
  60.                                 ,theme_advanced_toolbar_location : "top"
  61.                                 ,theme_advanced_toolbar_align : "left"
  62.                                 ,theme_advanced_statusbar_location : "bottom"
  63.                                 ,theme_advanced_resizing : true
  64.                                 ,theme_advanced_resize_horizontal : false
  65.                                 ,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
  66.                             });
  67.                         </script>
  68.         <td><textarea name="description" cols="75" id="id_description" style="width:450px; height:350px;"><? echo $row['description'];?></textarea></td>
  69.       </tr>
  70.       <tr>
  71.         <td>General Information</td>
  72.             <script type="text/javascript">
  73.                             tinyMCE.init({
  74.                                 mode : "exact"
  75.                                 ,elements : "id_general"
  76.                                 ,theme : "advanced"
  77.                                 ,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
  78.                                 ,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
  79.                                 ,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
  80.                                 ,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
  81.                                 ,theme_advanced_toolbar_location : "top"
  82.                                 ,theme_advanced_toolbar_align : "left"
  83.                                 ,theme_advanced_statusbar_location : "bottom"
  84.                                 ,theme_advanced_resizing : true
  85.                                 ,theme_advanced_resize_horizontal : false
  86.                                 ,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
  87.                             });
  88.                         </script>
  89.         <td><textarea style="width:450px; height:350px;" id="id_general" name="general"><? echo $row['general'];?></textarea></td>
  90.       </tr>
  91.       <tr>
  92.         <td>Terms &amp; Conditions</td>
  93.             <script type="text/javascript">
  94.                             tinyMCE.init({
  95.                                 mode : "exact"
  96.                                 ,elements : "id_terms"
  97.                                 ,theme : "advanced"
  98.                                 ,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
  99.                                 ,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
  100.                                 ,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
  101.                                 ,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
  102.                                 ,theme_advanced_toolbar_location : "top"
  103.                                 ,theme_advanced_toolbar_align : "left"
  104.                                 ,theme_advanced_statusbar_location : "bottom"
  105.                                 ,theme_advanced_resizing : true
  106.                                 ,theme_advanced_resize_horizontal : false
  107.                                 ,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
  108.                             });
  109.  
  110.                         </script>
  111.         <td><textarea style="width:450px; height:350px;" id="id_terms" name="terms"><? echo $row['terms'];?></textarea></td>
  112.       </tr>
  113.       <tr>
  114.         <td>About Us</td>
  115.         <script type="text/javascript">
  116.                             tinyMCE.init({
  117.                                 mode : "exact"
  118.                                 ,elements : "id_about"
  119.                                 ,theme : "advanced"
  120.                                 ,theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,formatselect,fontselect,fontsizeselect"
  121.                                 ,theme_advanced_buttons2 : "cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,|,image,charmap,emotions,iespell,media,advhr,|,ltr,rtl,|,code,fullscreen"
  122.                                 ,theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,"
  123.                                 ,theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,|,forecolor,backcolor"
  124.                                 ,theme_advanced_toolbar_location : "top"
  125.                                 ,theme_advanced_toolbar_align : "left"
  126.                                 ,theme_advanced_statusbar_location : "bottom"
  127.                                 ,theme_advanced_resizing : true
  128.                                 ,theme_advanced_resize_horizontal : false
  129.                                 ,plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups"
  130.                             });
  131.                         </script>
  132.         <td><textarea style="width:450px; height:350px;" id="id_about" name="about"><? echo $row['about'];?></textarea></td>
  133.       </tr>
  134.       <tr>
  135.         <td>Payment Methods</td>
  136.         <td><table width="192" border="0" cellspacing="0" cellpadding="0">
  137.             <tr>
  138.               <td width="134">&nbsp;</td>
  139.               <td width="58">&nbsp;</td>
  140.             </tr>
  141.             <tr>
  142.               <td>PayPal </td>
  143.               <td><input type="checkbox" name="payment01" id="payment01" value="<img src=http://theauctionwinners.com/resources/temp/paypal.gif>"/></td>
  144.             </tr>
  145.             <tr>
  146.               <td>Personal Cheques </td>
  147.               <td><input type="checkbox" name="payment02" id="payment02" value="<img src=http://theauctionwinners.com/resources/temp/cheque.gif>"/></td>
  148.             </tr>
  149.           </table></td>
  150.       </tr>
  151.       <tr>
  152.         <td colspan="2"><div align="center">
  153.           <p>
  154.         <center>  <input name="Submit" type="submit" value="Save Template" />
  155.           </form>
  156.  
DATABASE PAGE
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $username="username";
  3. $password="password";
  4. $database="database";
  5.  
  6. $rtrnURL = $_POST['rtrnURL'];
  7. $tempID = $_POST['tempID'];
  8. $htmlcss = $_POST['htmlcss'];
  9. $header = $_POST['header'];
  10. $nav = $_POST['nav'];
  11. $titleWrap01 = $_POST['titleWrap01'];
  12. $title = $_POST['title'];
  13. $titleWrap02 = $_POST['titleWrap02'];
  14. $subheadWrap01 = $_POST['subheadWrap01'];
  15. $subheading = $_POST['subheading'];
  16. $subheadWrap02 = $_POST['subheadWrap02'];
  17. $flashWrap01 = $_POST['flashWrap01'];
  18. $flashWrap02 = $_POST['flashWrap02'];
  19. $flash01 = $_POST['flash01'];
  20. $flashVar = $_POST['flashVar'];
  21. $flash02 = $_POST['flash02'];
  22. $flashWrap03 = $_POST['flashWrap03'];
  23. $descriptionWrap01 = $_POST['descriptionWrap01'];
  24. $description = $_POST['description'];
  25. $descriptionWrap02 = $_POST['descriptionWrap02'];
  26. $generalWrap01 = $_POST['generalWrap01'];
  27. $general = $_POST['general'];
  28. $generalWrap02 = $_POST['generalWrap02'];
  29. $aboutWrap01 = $_POST['aboutWrap01'];
  30. $about = $_POST['about'];
  31. $aboutWrap02 = $_POST['aboutWrap02'];
  32. $paymentWrap01 = $_POST['paymentWrap01'];
  33. $payment01 = $_POST['payment01'];
  34. $payment02 = $_POST['payment02'];
  35. $paymentWrap02 = $_POST['paymentWrap02'];
  36. $termsWrap01 = $_POST['termsWrap01'];
  37. $terms = $_POST['terms'];
  38. $termsWrap02 = $_POST['termsWrap02'];
  39. $footer = $_POST['footer'];
  40.  
  41. // OPEN CONNECTION ---> 
  42. $connection=mysql_connect("localhost" ,"$username", "$password") or die("Unable to connect!");
  43.  
  44. mysql_select_db("$database") or die("Unable to select database!");
  45.  
  46. // Select column 1 from table name where column name = $your_var.
  47. $sql = "SELECT * FROM savedTemps WHERE tempID = '{$tempID}'";
  48. // If mysql_query returns false, we'll die with the error.
  49. $res = mysql_query( $sql ) or die( mysql_error );
  50.  
  51. // If a there is a match
  52. if ( mysql_num_rows( $res ) > 0 )
  53. {
  54.  
  55. $query="
  56.  
  57. UPDATE savedTemps SET 
  58.  
  59.             htmlcss='{$htmlcss}', 
  60.             header='{$header}', 
  61.             nav='{$nav}', 
  62.             titleWrap01='{$titleWrap01}', 
  63.             title='{$title}',
  64.             titleWrap02='{$titleWrap02}',
  65.             subheadWrap01='{$subheadWrap01}', 
  66.             subheading='{$subheading}',
  67.             subheadWrap02='{$subheadWrap02}', 
  68.             flashWrap01='{$flashWrap01}',     
  69.             flashWrap02='{$flashWrap02}', 
  70.             flash01='{$flash01}', 
  71.             flashVar='{$flashVar}',
  72.             flash02='{$flash02}', 
  73.             flashWrap03='{$flashWrap03}',
  74.             descriptionWrap01='{$descriptionWrap01}',
  75.             description='{$description}', 
  76.             descriptionWrap02='{$descriptionWrap02}',
  77.             generalWrap01='{$generalWrap01}', 
  78.             general='{$general}', 
  79.             generalWrap02='{$generalWrap02}', 
  80.             aboutWrap01='{$aboutWrap01}',
  81.             about='{$about}', 
  82.             aboutWrap02='{$aboutWrap02}',
  83.             paymentWrap01='{$paymentWrap01}', 
  84.             payment01='{$payment01}', 
  85.             payment02='{$payment02}', 
  86.             paymentWrap02='{$paymentWrap02}',
  87.             termsWrap01='{$termsWrap01}', 
  88.             terms='{$terms}', 
  89.             termsWrap02='{$termsWrap02}',
  90.             footer='{$footer}'
  91.  
  92.             WHERE tempID='{$tempID}'";
  93. }
  94. else
  95. {
  96. //  EXECUTE QUERY ---> 
  97. $query="INSERT savedTemps (
  98.  
  99.             tempID, 
  100.             htmlcss, 
  101.             header, 
  102.             nav, 
  103.             titleWrap01, 
  104.             title,
  105.             titleWrap02,
  106.             subheadWrap01, 
  107.             subheading,
  108.             subheadWrap02, 
  109.             flashWrap01,     
  110.             flashWrap02, 
  111.             flash01, 
  112.             flashVar,
  113.             flash02, 
  114.             flashWrap03,
  115.             descriptionWrap01,
  116.             description, 
  117.             descriptionWrap02,
  118.             generalWrap01, 
  119.             general, 
  120.             generalWrap02, 
  121.             aboutWrap01,
  122.             about, 
  123.             aboutWrap02,
  124.             paymentWrap01, 
  125.             payment01, 
  126.             payment02, 
  127.             paymentWrap02,
  128.             termsWrap01, 
  129.             terms, 
  130.             termsWrap02,
  131.             footer)
  132.  
  133.         VALUES(    
  134.             '".$tempID."', 
  135.             '".$htmlcss."', 
  136.             '".$header."', 
  137.             '".$nav."', 
  138.             '".$titleWrap01."', 
  139.             '".$title."',
  140.             '".$titleWrap02."',
  141.             '".$subheadWrap01."', 
  142.             '".$subheading."',
  143.             '".$subheadWrap02."', 
  144.             '".$flashWrap01."',     
  145.             '".$flashWrap02."', 
  146.             '".$flash01."', 
  147.             '".$flashVar."', 
  148.             '".$flash02."', 
  149.             '".$flashWrap03."',
  150.             '".$descriptionWrap01."',
  151.             '".$description."', 
  152.             '".$descriptionWrap02."',
  153.             '".$generalWrap01."', 
  154.             '".$general."', 
  155.             '".$generalWrap02."', 
  156.             '".$aboutWrap01."',
  157.             '".$about."', 
  158.             '".$aboutWrap02."',
  159.             '".$paymentWrap01."', 
  160.             '".$payment01."', 
  161.             '".$payment02."', 
  162.             '".$paymentWrap02."',
  163.             '".$termsWrap01."', 
  164.             '".$terms."', 
  165.             '".$termsWrap02."',
  166.             '".$footer."')";
  167. }
  168.  
  169.  
  170. //////-----> 
  171. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  172. //if ($result) 
  173.     //echo mysql_affected_rows()." row inserted into the database effectively."; 
  174.  
  175. //  CLOSE CONNECTION ---> 
  176. mysql_close($connection); 
  177.  
  178. /////////////////////////////////////////////////////////////////////////////////// 
  179.  
  180. ?>
  181.  
Jul 22 '09 #5
Thank you both for your help!

I think I was able to progress! But there still seems to be a glitch somewhere, because I keep getting the mysql error message now???

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ("admintasks-dbcon.php");
  3. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  4. mysql_select_db($dbname);
  5.  
  6. $query = "SELECT * FROM $add_member";
  7. $result = mysql_query( $sql ) or die( mysql_error );
  8. if ( mysql_num_rows( $res ) > 0 )
  9. $query="
  10. UPDATE $add_member
  11. {
  12. else{
  13. INSERT INTO $add_member
  14. }
  15. (Name, Address 1, Address 2, City, State, Zip Code, Website, Contact Name, Position, Phone Number, Email Address) 
  16. VALUES {$_POST['name']},{$_POST['address 1']},{$_POST['address 2']},{$_POST['city']},{$_POST['state']},{$_POST['zip code']},{$_POST['website']},{$_POST['contact name']},{$_POST['position']},{$_POST['phone number']},{$_POST['email address']})";
  17.  
  18. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  19. if ($result) 
  20. echo mysql_affected_rows()." row inserted into the database effectively."; 
  21.  
  22. mysql_close($connection); 
  23. }
  24. ?>
  25.  
I also need the page to go onto a thank you page or an error page if all of the information has not been entered. I know that I would use header("Location: page name");

but where would I put this???
Jul 23 '09 #6
anfetienne
424 256MB
ok....well for starters you haven't set anything to the UPDATE i.e.

Expand|Select|Wrap|Line Numbers
  1. UPDATE savedTemps SET 
  2.  
  3. htmlcss='{$htmlcss}', 
  4. header='{$header}', 
  5. nav='{$nav}', 
  6. titleWrap01='{$titleWrap01}', 
  7. title='{$title}',
  8. titleWrap02='{$titleWrap02}',
  9. subheadWrap01='{$subheadWrap01}', 
  10. subheading='{$subheading}',
  11. subheadWrap02='{$subheadWrap02}', 
  12. flashWrap01='{$flashWrap01}',     
  13. flashWrap02='{$flashWrap02}', 
  14. flash01='{$flash01}', 
  15. flashVar='{$flashVar}',
  16. flash02='{$flash02}', 
  17. flashWrap03='{$flashWrap03}',
  18. descriptionWrap01='{$descriptionWrap01}',
  19. description='{$description}', 
  20. descriptionWrap02='{$descriptionWrap02}',
  21. generalWrap01='{$generalWrap01}', 
  22. general='{$general}', 
  23. generalWrap02='{$generalWrap02}', 
  24. aboutWrap01='{$aboutWrap01}',
  25. about='{$about}', 
  26. aboutWrap02='{$aboutWrap02}',
  27. paymentWrap01='{$paymentWrap01}', 
  28. payment01='{$payment01}', 
  29. payment02='{$payment02}', 
  30. paymentWrap02='{$paymentWrap02}',
  31. termsWrap01='{$termsWrap01}', 
  32. terms='{$terms}', 
  33. termsWrap02='{$termsWrap02}',
  34. footer='{$footer}'
  35.  
  36. WHERE tempID='{$tempID}'";
  37.  
and you have sql coding in the wrong place.....bare with me a sec
Jul 23 '09 #7
anfetienne
424 256MB
try this....i've seperated it all so you can see clearer what i've done.

also maybe you should think about giving people a member ID it would be easier to update table fields using it since it's the only item that doesn't and maybe won't change....or a username???

a random digit is good for memberID, put it on the page where the form is and include it in a hidden field in your form like this:

MEMBER ID
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $memberID=rand(0000000,9999999);
  3. ?>
  4.  
  5. <input type="hidden" name="memberID" id="memberID" value="<?php print $memberID;?>" /> 
  6.  
FULL CODE
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ("admintasks-dbcon.php");
  3. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  4. mysql_select_db($dbname);
  5.  
  6. $query = "SELECT * FROM $add_member WHERE memberID = '{$memberID}'";
  7. $result = mysql_query( $sql ) or die( mysql_error );
  8.  
  9. if ( mysql_num_rows( $res ) > 0 )
  10. //and here you had no data specified or fields specified
  11.  
  12. $query="
  13. UPDATE $add_member SET
  14.             name = '{$_POST['name']}', 
  15.             address 1 = '{$_POST['address 1']}', 
  16.             address 2 = '{$_POST['address 2']}',
  17.             City='{$_POST['city']}', 
  18.             State = '{$_POST['state']}', 
  19.             Zip Code = '{$_POST['zip code']}',
  20.             Website = '{$_POST['website']}'
  21.             Contact Name = '{$_POST['contact name']}',
  22.             Position = '{$_POST['position']}',
  23.             Phone Number = '{$_POST['phone number']}',
  24.             Email Address = '{$_POST['email address']}')
  25.  
  26.             WHERE memberID ='{$memberID}'";
  27. {
  28. else{
  29. //in this section you had the following...your sql wasn't inside the loop and also there was no $query=""
  30.  
  31. # INSERT INTO $add_member
  32. # }
  33. # (Name, Address 1, Address 2, City, State, Zip Code, Website, Contact Name, Position, Phone Number, Email Address) 
  34. # VALUES {$_POST['name']},{$_POST['address 1']},{$_POST['address 2']},{$_POST['city']},{$_POST['state']},{$_POST['zip code']},{$_POST['website']},{$_POST['contact name']},{$_POST['position']},{$_POST['phone number']},{$_POST['email address']})";
  35. #  
  36. $query="
  37.  
  38. INSERT INTO $add_member (
  39.  
  40.             Member ID,    
  41.             Name,
  42.             Address 1,
  43.             Address 2,
  44.             City, 
  45.             State, 
  46.             Zip Code, 
  47.             Website, 
  48.             Contact Name, 
  49.             Position, 
  50.             Phone Number, 
  51.             Email Address)
  52.  
  53. VALUES 
  54.  
  55.             {$_POST['memberID']},
  56.             {$_POST['name']},
  57.             {$_POST['address 1']},
  58.             {$_POST['address 2']},
  59.             {$_POST['city']},
  60.             {$_POST['state']},
  61.             {$_POST['zip code']},
  62.             {$_POST['website']},
  63.             {$_POST['contact name']},
  64.             {$_POST['position']},
  65.             {$_POST['phone number']},
  66.             {$_POST['email address']})";
  67.  
  68. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  69.  
  70. if ( mysql_num_rows( $result ) > 0 ) 
  71. echo mysql_affected_rows()." row inserted into the database effectively."; 
  72.  
  73. mysql_close(); 
  74. }
  75.  
  76. session_start();
  77. $_SESSION["Name"] = $_POST['name'];
  78. header("location:thankYou.php");
  79. ?>
  80.  
Jul 23 '09 #8
anfetienne
424 256MB
and on your following page if you wanted to say

"Thank You (Member's Name),"

use this code to include it in

Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. $Name = $_SESSION["Name"];
  4. ?>
  5.  
  6. //example
  7. "Thank You <?php print $Name;?>, for registering!"
  8.  
Jul 23 '09 #9
anfetienne
424 256MB
also 1 question.....

in your config file is $add_member = add_member???
Jul 23 '09 #10
I am not sure what you mean by config, file unless you mean the file that connects to mysql and in that case no it is just add_member for the table name.

Is that what you are asking?

I have not tried your scripting yet, but I will and thank you. I will let you know if that is successful.
Jul 23 '09 #11
anfetienne
424 256MB
yeah....if thats the case you need to take the dollar sign off your sql code so its

INSERT INTO add_member and SELECT * FROM add_member
Jul 23 '09 #12
Well thank you for all that help! I have made the changes you suggested and am now getting this error:

Parse error: syntax error, unexpected T_ELSE in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 27

Here is the code I am using:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ("admintasks-dbcon.php");
  3. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  4. mysql_select_db($dbname);  
  5. $query = "SELECT * FROM add_member WHERE memberID = '{$memberID}'";
  6. $result = mysql_query( $sql ) or die( mysql_error );
  7.  
  8. if ( mysql_num_rows( $res ) > 0 )
  9.  
  10. $query="
  11. UPDATE add_member SET
  12.             name = '{$_POST['name']}', 
  13.             address 1 = '{$_POST['address 1']}', 
  14.             address 2 = '{$_POST['address 2']}',
  15.             City='{$_POST['city']}', 
  16.             State = '{$_POST['state']}', 
  17.             Zip Code = '{$_POST['zip code']}',
  18.             Website = '{$_POST['website']}'
  19.             Contact Name = '{$_POST['contact name']}',
  20.             Position = '{$_POST['position']}',
  21.             Phone Number = '{$_POST['phone number']}',
  22.             Email Address = '{$_POST['email address']}')
  23.  
  24. WHERE memberID ='{$memberID}'";
  25. {
  26. else{
  27.  
  28. $query="
  29.  
  30. INSERT INTO add_member (
  31.  
  32.             Member ID,    
  33.             Name,
  34.             Address 1,
  35.             Address 2,
  36.             City, 
  37.             State, 
  38.             Zip Code, 
  39.             Website, 
  40.             Contact Name, 
  41.             Position, 
  42.             Phone Number, 
  43.             Email Address)
  44.  
  45. VALUES 
  46.  
  47.             {$_POST['memberID']},
  48.             {$_POST['name']},
  49.             {$_POST['address 1']},
  50.             {$_POST['address 2']},
  51.             {$_POST['city']},
  52.             {$_POST['state']},
  53.             {$_POST['zip code']},
  54.             {$_POST['website']},
  55.             {$_POST['contact name']},
  56.             {$_POST['position']},
  57.             {$_POST['phone number']},
  58.             {$_POST['email address']})";
  59.  
  60. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  61.  
  62. if ( mysql_num_rows( $result ) > 0 ) 
  63. echo mysql_affected_rows()." row inserted into the database effectively."; 
  64.  
  65. mysql_close(); 
  66. }
  67.  
  68. session_start();
  69. $_SESSION["Name"] = $_POST['name'];
  70. header("location:thankyouforbecomingamember.php");
  71. ?>
  72.  
Jul 27 '09 #13
anfetienne
424 256MB
on line 26 you haven't closed the previous loop

change { to } and it should work
Jul 27 '09 #14
Dormilich
8,658 Expert Mod 8TB
those errors are easily fixed if you keep an eye on your syntax (and a good editor helps a lot here, because it can show you which parentheses/brackets belong together)
Jul 27 '09 #15
Now it is just saying  mysql_error

Does this mean it could not connect to mysql or that the information could not be added for some reason???
Jul 27 '09 #16
anfetienne
424 256MB
im wondering if its because of these on your sql insert

{$_POST['email address']}

try put it within quotes like below and see if that helps? (note it is a single quote then double quote)

'"{$_POST['email address']}"'

or assign them to vars like i have done in this code below

Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. if(!$_SESSION['myusername']){
  4. header("location:index.php");
  5. }
  6.  
  7. include ("admin-dbcon.php");
  8.  
  9. $rtrnURL = $_POST['rtrnURL'];
  10. $tempID = $_POST['tempID'];
  11. $htmlcss = $_POST['htmlcss'];
  12. $header = $_POST['header'];
  13. $nav = $_POST['nav'];
  14. $titleWrap01 = $_POST['titleWrap01'];
  15. $title = $_POST['title'];
  16. $titleWrap02 = $_POST['titleWrap02'];
  17. $subheadWrap01 = $_POST['subheadWrap01'];
  18. $subheading = $_POST['subheading'];
  19. $subheadWrap02 = $_POST['subheadWrap02'];
  20. $flashWrap01 = $_POST['flashWrap01'];
  21. $flashWrap02 = $_POST['flashWrap02'];
  22. $flash01 = $_POST['flash01'];
  23. $flashVar = $_POST['flashVar'];
  24. $flash02 = $_POST['flash02'];
  25. $flashWrap03 = $_POST['flashWrap03'];
  26. $descriptionWrap01 = $_POST['descriptionWrap01'];
  27. $description = $_POST['description'];
  28. $descriptionWrap02 = $_POST['descriptionWrap02'];
  29. $generalWrap01 = $_POST['generalWrap01'];
  30. $general = $_POST['general'];
  31. $generalWrap02 = $_POST['generalWrap02'];
  32. $aboutWrap01 = $_POST['aboutWrap01'];
  33. $about = $_POST['about'];
  34. $aboutWrap02 = $_POST['aboutWrap02'];
  35. $paymentWrap01 = $_POST['paymentWrap01'];
  36. $payment01 = $_POST['payment01'];
  37. $payment02 = $_POST['payment02'];
  38. $paymentWrap02 = $_POST['paymentWrap02'];
  39. $termsWrap01 = $_POST['termsWrap01'];
  40. $terms = $_POST['terms'];
  41. $termsWrap02 = $_POST['termsWrap02'];
  42. $footer = $_POST['footer'];
  43.  
  44. // OPEN CONNECTION ---> 
  45. mysql_connect($hostname,$username,$password);
  46. @mysql_select_db($database) or die( "Unable to select database");
  47.  
  48. // Select column 1 from table name where column name = $your_var.
  49. $sql = "SELECT * FROM savedTemps WHERE tempID = '{$tempID}'";
  50. // If mysql_query returns false, we'll die with the error.
  51. $res = mysql_query( $sql ) or die( mysql_error );
  52.  
  53. // If a there is a match
  54. if ( mysql_num_rows( $res ) > 0 )
  55. {
  56.  
  57. $query="
  58.  
  59. UPDATE savedTemps SET 
  60.  
  61.             htmlcss='{$htmlcss}', 
  62.             header='{$header}', 
  63.             nav='{$nav}', 
  64.             titleWrap01='{$titleWrap01}', 
  65.             title='{$title}',
  66.             titleWrap02='{$titleWrap02}',
  67.             subheadWrap01='{$subheadWrap01}', 
  68.             subheading='{$subheading}',
  69.             subheadWrap02='{$subheadWrap02}', 
  70.             flashWrap01='{$flashWrap01}',     
  71.             flashWrap02='{$flashWrap02}', 
  72.             flash01='{$flash01}', 
  73.             flashVar='{$flashVar}',
  74.             flash02='{$flash02}', 
  75.             flashWrap03='{$flashWrap03}',
  76.             descriptionWrap01='{$descriptionWrap01}',
  77.             description='{$description}', 
  78.             descriptionWrap02='{$descriptionWrap02}',
  79.             generalWrap01='{$generalWrap01}', 
  80.             general='{$general}', 
  81.             generalWrap02='{$generalWrap02}', 
  82.             aboutWrap01='{$aboutWrap01}',
  83.             about='{$about}', 
  84.             aboutWrap02='{$aboutWrap02}',
  85.             paymentWrap01='{$paymentWrap01}', 
  86.             payment01='{$payment01}', 
  87.             payment02='{$payment02}', 
  88.             paymentWrap02='{$paymentWrap02}',
  89.             termsWrap01='{$termsWrap01}', 
  90.             terms='{$terms}', 
  91.             termsWrap02='{$termsWrap02}',
  92.             footer='{$footer}'
  93.  
  94.             WHERE tempID='{$tempID}'";
  95. }
  96. else
  97. {
  98. //  EXECUTE QUERY ---> 
  99. $query="INSERT savedTemps (
  100.  
  101.             tempID, 
  102.             htmlcss, 
  103.             header, 
  104.             nav, 
  105.             titleWrap01, 
  106.             title,
  107.             titleWrap02,
  108.             subheadWrap01, 
  109.             subheading,
  110.             subheadWrap02, 
  111.             flashWrap01,     
  112.             flashWrap02, 
  113.             flash01, 
  114.             flashVar,
  115.             flash02, 
  116.             flashWrap03,
  117.             descriptionWrap01,
  118.             description, 
  119.             descriptionWrap02,
  120.             generalWrap01, 
  121.             general, 
  122.             generalWrap02, 
  123.             aboutWrap01,
  124.             about, 
  125.             aboutWrap02,
  126.             paymentWrap01, 
  127.             payment01, 
  128.             payment02, 
  129.             paymentWrap02,
  130.             termsWrap01, 
  131.             terms, 
  132.             termsWrap02,
  133.             footer)
  134.  
  135.         VALUES(    
  136.             '".$tempID."', 
  137.             '".$htmlcss."', 
  138.             '".$header."', 
  139.             '".$nav."', 
  140.             '".$titleWrap01."', 
  141.             '".$title."',
  142.             '".$titleWrap02."',
  143.             '".$subheadWrap01."', 
  144.             '".$subheading."',
  145.             '".$subheadWrap02."', 
  146.             '".$flashWrap01."',     
  147.             '".$flashWrap02."', 
  148.             '".$flash01."', 
  149.             '".$flashVar."', 
  150.             '".$flash02."', 
  151.             '".$flashWrap03."',
  152.             '".$descriptionWrap01."',
  153.             '".$description."', 
  154.             '".$descriptionWrap02."',
  155.             '".$generalWrap01."', 
  156.             '".$general."', 
  157.             '".$generalWrap02."', 
  158.             '".$aboutWrap01."',
  159.             '".$about."', 
  160.             '".$aboutWrap02."',
  161.             '".$paymentWrap01."', 
  162.             '".$payment01."', 
  163.             '".$payment02."', 
  164.             '".$paymentWrap02."',
  165.             '".$termsWrap01."', 
  166.             '".$terms."', 
  167.             '".$termsWrap02."',
  168.             '".$footer."')";
  169. }
  170.  
  171.  
  172. //////-----> 
  173. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  174. //if ($result) 
  175.     //echo mysql_affected_rows()." row inserted into the database effectively."; 
  176.  
  177. //  CLOSE CONNECTION ---> 
  178. mysql_close(); 
  179. ?>
  180. <script language="JavaScript">
  181. <!--
  182. window.location="<? print $rtrnURL?>";
  183. //-->
  184. </SCRIPT>
  185.  
can you export you sql table to a text file and attach it to a post so i can test and see where you code is going wrong?
Jul 27 '09 #17
Database mideasthonors

Table structure for table add_member

Field Type Null Default
Institution varchar(45) No
Address 1 varchar(45) No
Address 2 varchar(45) No
City varchar(45) No
State varchar(2) No
Zip Code int(5) No 0
Website text No
Contact Name varchar(45) No
Position varchar(25) No
Phone Number int(12) No 0
Email text No

Dumping data for table add_member
Institution Address 1 Address 2 City State Zip Code Website Contact Name Position Phone Number Email
Jul 27 '09 #18
Dormilich
8,658 Expert Mod 8TB
@anfetienne
this would be a good place to apply mysql_real_escape_string() to prevent SQL injection
Jul 27 '09 #19
anfetienne
424 256MB
that is a good idea dorm....as always

im going to test this on mine
Jul 27 '09 #20
Well I tried both of your suggestions and I keep getting the same result:


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 13

This is my script:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ("admintasks-dbcon.php");
  3. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  4. mysql_select_db($dbname);  
  5. $query = "SELECT * FROM add_member WHERE memberID = '{$memberID}'";
  6. $result = mysql_query( $sql ) or die( mysql_error );
  7.  
  8. if ( mysql_num_rows( $res ) > 0 )
  9.  
  10. $query="
  11. UPDATE add_member SET
  12.             $name = $_POST['name'], 
  13.             $address 1 = $_POST['address 1'], 
  14.             $address 2 = $_POST['address 2'],
  15.             $City= $_POST['city'], 
  16.             $State = $_POST['state'], 
  17.             $Zip Code = $_POST['zip code'],
  18.             $Website = $_POST['website'],
  19.             $Contact Name = $_POST['contact name'],
  20.             $Position = $_POST['position'],
  21.             $Phone Number = $_POST['phone number'],
  22.             $Email Address = $_POST['email address'])
  23.  
  24. WHERE memberID ='{$memberID}'";
  25. }
  26. else{
  27.  
  28. $query="
  29.  
  30. INSERT INTO add_member (
  31.  
  32.             Member ID,    
  33.             Name,
  34.             Address 1,
  35.             Address 2,
  36.             City, 
  37.             State, 
  38.             Zip Code, 
  39.             Website, 
  40.             Contact Name, 
  41.             Position, 
  42.             Phone Number, 
  43.             Email Address)
  44.  
  45. VALUES 
  46.  
  47.             {$_POST['memberID']},
  48.             {$_POST['name']},
  49.             {$_POST['address 1']},
  50.             {$_POST['address 2']},
  51.             {$_POST['city']},
  52.             {$_POST['state']},
  53.             {$_POST['zip code']},
  54.             {$_POST['website']},
  55.             {$_POST['contact name']},
  56.             {$_POST['position']},
  57.             {$_POST['phone number']},
  58.             {$_POST['email address']})";
  59.  
  60. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  61.  
  62. if ( mysql_num_rows( $result ) > 0 ) 
  63. echo mysql_affected_rows()." row inserted into the database effectively."; 
  64.  
  65. mysql_close(); 
  66. }
  67.  
  68. session_start();
  69. $_SESSION["Name"] = $_POST['name'];
  70. header("location:thankyouforbecomingamember.php");
  71. ?>
  72.  
Jul 27 '09 #21
Dormilich,
Would I place it before each item that will be entered by the person becoming a member?

For example:
mysql_real_escape_string (name = $_POST['name']),

Would that we right?
Jul 27 '09 #22
Dormilich
8,658 Expert Mod 8TB
@mideastgirl
of course, look again at anfetienne's sample code and try to figure out the differences you made (despite the variable names)
Jul 27 '09 #23
Dormilich
8,658 Expert Mod 8TB
@mideastgirl
nope, this way you'd not use mysql_real_escape_string() at all (beside getting a warning for undefined constants). refer to the manual for the correct syntax.

sorry for the rather inconvenient way of my answer, but you need to learn those basic syntax stuff.
Jul 27 '09 #24
Dormilich
8,658 Expert Mod 8TB
@anfetienne
I'll stick to Prepared Statements--much safer than only escaping the data.

although PHP Filters are quite useful too.
Jul 27 '09 #25
Noticed the difference between the two was the semi-colons at the end instead of the commas I used. I have replaced the commas with semi-colons but the problem is still happening!:(
Jul 27 '09 #26
Dormilich
8,658 Expert Mod 8TB
one more hint.

check where anfetienne defined his variables.
Jul 27 '09 #27
anfetienne
424 256MB
one thing that has been bugging my brains on this is......is this a 1st process sign up?

i.e. is this page used to sign members up? if so there may not be a need for the UPDATE....you just do a straight INSERT
Jul 27 '09 #28
Dormilich
8,658 Expert Mod 8TB
@anfetienne
according to the page.... yes
Jul 27 '09 #29
anfetienne
424 256MB
if its a sign up page then there is no need for the UPDATE query, it should be SELECT to check if the member exists

ok one problem of yours lies here, you have variables where the names of you table cloumns should be. take the dollar sign off and that may work.

Expand|Select|Wrap|Line Numbers
  1.  UPDATE add_member SET
  2.              $name = $_POST['name'], 
  3.              $address 1 = $_POST['address 1'], 
  4.              $address 2 = $_POST['address 2'],
  5.              $City= $_POST['city'], 
  6.              $State = $_POST['state'], 
  7.              $Zip Code = $_POST['zip code'],
  8.              $Website = $_POST['website'],
  9.              $Contact Name = $_POST['contact name'],
  10.              $Position = $_POST['position'],
  11.              $Phone Number = $_POST['phone number'],
  12.              $Email Address = $_POST['email address'])
  13.  
  14.             WHERE memberID ='{$memberID}'";
  15.  
secondly when inserting you really should use quotes where the values are....i.e. where you have {$_POST['email address']} is should be within quotes

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO add_member (
  2.  
  3.              memberID,    
  4.              Name,
  5.              Address 1,
  6.              Address 2,
  7.              City, 
  8.              State, 
  9.              Zip Code, 
  10.              Website, 
  11.              Contact Name, 
  12.              Position, 
  13.              Phone Number, 
  14.              Email Address)
  15.  
  16.  VALUES 
  17.  
  18.              {$_POST['memberID']},
  19.              {$_POST['name']},
  20.              {$_POST['address 1']},
  21.              {$_POST['address 2']},
  22.              {$_POST['city']},
  23.              {$_POST['state']},
  24.              {$_POST['zip code']},
  25.              {$_POST['website']},
  26.              {$_POST['contact name']},
  27.              {$_POST['position']},
  28.              {$_POST['phone number']},
  29.              {$_POST['email address']})";
  30.  
thirdly the sql you gave did not have a memerID column, you are running a SQL UPDATE to a specified column that doesn't exist. also on the UPDATE you have $memberID but no values assigned to the variable.
Jul 27 '09 #30
anfetienne
424 256MB
there are also errors on your form and error in sql connection....

e.g.

zip code on your form is named zip and in your php zip code
Jul 27 '09 #31
Ok I have updated the php document I am still returning a mysql error. I added member ID as a column in my table, I have updated zip to zip code within the table as well. I have added quotes around the values. I am not sure what I should do next!
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ("admintasks-dbcon.php");
  3. mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  4. mysql_select_db($dbname);  
  5. $query = "SELECT * FROM add_member WHERE memberID = '{$memberID}'";
  6. $result = mysql_query( $sql ) or die( mysql_error );
  7.  
  8. if ( mysql_num_rows( $res ) > 0 )
  9.  
  10. $query="
  11. SELECT add_member SET
  12.             name = $_POST ['name']; 
  13.             address 1 = $_POST ['address 1']; 
  14.             address 2 = $_POST ['address 2'];
  15.             City= $_POST ['city']; 
  16.             State = $_POST ['state']; 
  17.             Zip Code = $_POST ['zip code'];
  18.             Website = $_POST ['website'];
  19.             Contact Name = $_POST ['contact name'];
  20.             Position = $_POST ['position'];
  21.             Phone Number = $_POST ['phone number'];
  22.             Email Address = $_POST ['email address'];)
  23.  
  24. WHERE memberID ='{$memberID}'";
  25. }
  26. else{
  27.  
  28. $query="
  29.  
  30. INSERT INTO add_member (
  31.  
  32.             'Member ID',    
  33.             'Name',
  34.             'Address 1',
  35.             'Address 2',
  36.             'City', 
  37.             'State', 
  38.             'Zip Code', 
  39.             'Website', 
  40.             'Contact Name', 
  41.             'Position', 
  42.             'Phone Number', 
  43.             'Email Address')
  44.  
  45. VALUES 
  46.  
  47.             '{$_POST['memberID']}',
  48.             '{$_POST['name']}',
  49.             '{$_POST['address 1']}',
  50.             '{$_POST['address 2']}',
  51.             '{$_POST['city']}',
  52.             '{$_POST['state']}',
  53.             '{$_POST['zip code']}',
  54.             '{$_POST['website']}',
  55.             '{$_POST['contact name']}',
  56.             '{$_POST['position']}',
  57.             '{$_POST['phone number']}',
  58.             '{$_POST['email address']}')";
  59.  
  60. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  61.  
  62. if ( mysql_num_rows( $result ) > 0 ) 
  63. echo mysql_affected_rows()." row inserted into the database effectively."; 
  64.  
  65. mysql_close(); 
  66. }
  67.  
  68. session_start();
  69. $_SESSION["Name"] = $_POST['name'];
  70. header("location:thankyouforbecomingamember.php");
  71. ?>
  72.  
Here is the table:

Institution MemberID Address 1 Address 2 City State Zip Code Website Contact Name Position Phone Number Email
Jul 27 '09 #32
anfetienne
424 256MB
ok i have corrected everything from your form down to the database. here is the coding of each page. they are saved as the name states as php files (i have attached a zip with all files).....

to see it in action go to database test

index.php (form page)

Expand|Select|Wrap|Line Numbers
  1.  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  <html xmlns="http://www.w3.org/1999/xhtml">
  3.  
  4.  <head>
  5.  <meta http-equiv="Content-Language" content="en-us" />
  6.  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7.  <title>Error</title>
  8.  <style type="text/css">
  9.  .style1 {
  10.      font-family: Arial, Helvetica, sans-serif;
  11.      font-size: medium;
  12.  }
  13.  
  14.  .style29 {
  15.      font-family: Arial, Helvetica, sans-serif;
  16.  }
  17.  h2 {
  18.      font-family: Verdana, Arial, Helvetica, sans-serif;
  19.      font-size: 17px;
  20.      font-weight: bold;
  21.      color: #2F77F1;
  22.      line-height: 20px;
  23.  }
  24.  .style30 {
  25.      font-family: geneva, arial;
  26.      font-size: 10pt;
  27.  }
  28.  
  29.  .style31 {
  30.      font-family: Verdana, Arial, Helvetica, sans-serif;
  31.      font-size: 12px;
  32.      line-height: 11pt;
  33.      margin: 3px 0;
  34.      padding-bottom: 9px;
  35.  }
  36.  </style>
  37.  </head>
  38.  
  39.  <body>
  40.   <?php $memberID = rand(0000000000,9999999999);?>
  41.  <p class="style1"><strong>Error: All fields have not been filled in, or information is inaccurate. Please complete form.</strong></p>
  42.  <form method="post" action="addmember.php" style="width: 169px">
  43.  *<input type="hidden" name="memberID" id="memberID" value="<?php print $memberID;?>" />
  44.  
  45.      <table>
  46.  
  47.          <tr>
  48.              <td colspan=2><h2 class="style29">Institution Information</h2></td>
  49.          </tr>
  50.  
  51.          <tr>
  52.              <td class='style30'><p class="style31"><label for='name'>Institution*</label></p></td>
  53.              <td class="style30"><input type="text" name="institution" size=45 maxlength=100 value="" /></td>
  54.          </tr>
  55.  
  56.          <tr>
  57.              <td class='style30'><p class="style31"><label for='address_1'>Address*</label></p></td>
  58.              <td class="style30"><input type="text" name="address1" size=45 maxlength=100 value="" /></td>
  59.          </tr>
  60.  
  61.          <tr>
  62.              <td class="style30">&nbsp;</td>
  63.              <td class="style30"><input type="text" name="address2" size=45 maxlength=100 value="" /></td>
  64.          </tr>
  65.  
  66.          <tr>
  67.              <td class='style30'><p class="style31"><label for='city'>City*</label></p></td>
  68.              <td class="style30"><input type="text" name="city" size=45 maxlength=50 value="" /></td>
  69.          </tr>
  70.  
  71.          <tr>
  72.              <td class='style30'><p class="style31"><label for='state'>State*</label>
  73.              <td class="style30">
  74.                  <select name='state'>
  75.                  <?php
  76.                  $states = array("Illinois", "Indiana", "Kentucky", "Michigan", "Ohio", "Pennsylvania", "Tennessee", "West Viriginia");
  77.                  foreach($states as $a => $value){
  78.                      echo "<option name=".$value ." value=".$value .">$value</option>";
  79.                  }
  80.                  ?>
  81.                  </select>
  82.              </td>
  83.          </tr>
  84.  
  85.          <tr>
  86.              <td class='style30'><p class="style31"><label for='zip'>ZIP Code*</label></p></td>
  87.              <td class="style30"><input type="text" name="zip" size=10 maxlength=10 value="" /></td>
  88.          </tr>
  89.  
  90.          <tr>
  91.              <td class='style30'><p class="style31"><label for='website'>Website*</label></p></td>
  92.              <td class="style30"><input type="text" name="website" value="http://www." size=45 maxlength=100 value="" /></td>
  93.          </tr>
  94.  
  95.          <tr>
  96.              <td colspan=2><h2 class="style29">Contact Information</h2></td>
  97.          </tr>
  98.  
  99.          <tr>
  100.              <td class='style30'><p class="style31"><label for='contact_name'>Contact Name*</label></p></td>
  101.              <td class="style30"><input type="text" name="contactName" size=45 maxlength=100 value="" /></td>
  102.          </tr>
  103.  
  104.          <tr>
  105.              <td class='style30'><p class="style31"><label for='contact_position'>Position</label></p></td>
  106.              <td class="style30"><input type="text" name="position" size=45 maxlength=100 value="" /></td>
  107.          </tr>
  108.  
  109.          <tr>
  110.              <td class='style30'><p class="style31"><label for='contact_phone'>Phone Number*</label></p></td>
  111.              <td class="style30"><input type="text" name="phone" size=14 maxlength=14 value="" /></td>
  112.          </tr>
  113.  
  114.          <tr>
  115.              <td class='style30'><p class="style31"><label for='contact_email'>Email Address*</label></p></td>
  116.              <td class="style30"><input type="text" name="email" size=45 maxlength=100 value="" /></td>
  117.          </tr>
  118.  
  119.          <tr>
  120.              <td class="style30">&nbsp;</td>
  121.              <td class="style30"><input type="submit" name ="Add Member" value="Add Member" /></td>
  122.          </tr>
  123.  
  124.     </table>
  125.  
addmember.php (please note how i assigned variables to each $_POST and used lower case on all first words the capitals on second words with no spaces this helps it be read easier with no confusion. The UPDATE query has been removed as its for signups and take note of how i put the variables in single and double quotes for the values in the INSERT query. this is how it should have been and this is what you were missing before along with all other mistakes and naming mistakes)

Expand|Select|Wrap|Line Numbers
  1. <? error_reporting(E_ALL);
  2.  
  3. include ("admintasks-dbcon.php");
  4.  
  5. $memberID = $_POST['memberID'];
  6. $institution = $_POST['institution'];
  7. $address1 = $_POST['address1']; 
  8. $address2 = $_POST['address2'];
  9. $city = $_POST['city'];
  10. $state = $_POST['state'];
  11. $zipCode = $_POST['zip'];
  12. $website = $_POST['website'];
  13. $contactName = $_POST['contactName'];
  14. $position = $_POST['position'];
  15. $phoneNumber = $_POST['phone'];
  16. $email = $_POST['email'];
  17.  
  18. // OPEN CONNECTION ---> 
  19. mysql_connect($hostname,$username,$password);
  20. @mysql_select_db($database) or die( "Unable to select database");
  21.  
  22.  
  23.  $sql = "SELECT * FROM addMember WHERE email = '{$email}'";
  24.  $res = mysql_query( $sql ) or die( mysql_error );
  25.  
  26.  if ( mysql_num_rows( $res ) > 0 )
  27.  { 
  28.  
  29. session_start();
  30. $_SESSION["contactName"] = $contactName;
  31. header("location:alreadyMember.php");
  32.  
  33.  }
  34.  else{
  35.  
  36.  $query="INSERT addMember (
  37.  
  38.              memberID,    
  39.              institution,
  40.              address1,
  41.              address2,
  42.              city, 
  43.              state, 
  44.              zip, 
  45.              website, 
  46.              contactName, 
  47.              position, 
  48.              phoneNumber, 
  49.              email)
  50.  
  51.  VALUES (    
  52.              '".$memberID."',
  53.              '".$institution."',
  54.              '".$address1."',
  55.              '".$address2."',
  56.              '".$city."',
  57.              '".$state."',
  58.              '".$zipCode."',
  59.              '".$website."',
  60.              '".$contactName."',
  61.              '".$position."',
  62.              '".$phoneNumber."',
  63.              '".$email."')";
  64.  
  65. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  66.  
  67. session_start();
  68. $_SESSION["contactName"] = $contactName;
  69. header("location:thankYou.php");
  70. }
  71.  
  72. mysql_close();
  73.  
  74. ?>
  75.  
thankYou.php (please note the session start at the top and how their name is including on the page)

Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. $contactName = $_SESSION["contactName"];
  4. ?>
  5.  
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <title>Untitled Document</title>
  11. </head>
  12.  
  13. <body>
  14. Thank You <?php echo $contactName;?>... You have signed up SUCCESSFULLY!
  15. </body>
  16. </html>
  17.  
alreadyMember.php (note the same as above)

Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. $contactName = $_SESSION["contactName"];
  4. ?>
  5.  
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <title>Untitled Document</title>
  11. </head>
  12.  
  13. <body>
  14. We're Sorry <?php echo $contactName;?>... But it seems that you are already a member!
  15. </body>
  16. </html>
  17.  
MySql Table Structure (please take note of the columns ive included and as above how i have named them lower case first words wit Capital second words for ease....please delete the add_member table you already have and import the addMember.sql file included within the attached zip file)

Expand|Select|Wrap|Line Numbers
  1. -- phpMyAdmin SQL Dump
  2. -- version 2.11.9.5
  3. -- http://www.phpmyadmin.net
  4. --
  5. -- Host: localhost
  6. -- Generation Time: Jul 27, 2009 at 10:47 AM
  7. -- Server version: 5.0.77
  8. -- PHP Version: 5.2.6
  9.  
  10. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  11.  
  12. --
  13. -- Database: `theau10_resources`
  14. --
  15.  
  16. -- --------------------------------------------------------
  17.  
  18. --
  19. -- Table structure for table `addMember`
  20. --
  21.  
  22. CREATE TABLE IF NOT EXISTS `addMember` (
  23.   `id` int(6) NOT NULL auto_increment,
  24.   `memberID` int(12) NOT NULL,
  25.   `institution` varchar(45) NOT NULL,
  26.   `address1` varchar(45) NOT NULL,
  27.   `address2` varchar(45) NOT NULL,
  28.   `city` varchar(45) NOT NULL,
  29.   `state` varchar(2) NOT NULL,
  30.   `zip` int(10) NOT NULL,
  31.   `website` text NOT NULL,
  32.   `contactName` varchar(45) NOT NULL,
  33.   `position` varchar(25) NOT NULL,
  34.   `phoneNumber` int(12) NOT NULL,
  35.   `email` text NOT NULL,
  36.   PRIMARY KEY  (`id`)
  37. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  38.  
  39. --
  40. -- Dumping data for table `addMember`
  41. --
  42.  
  43.  
  44.  
admintasks-dbcon.php (update this to your details)

Expand|Select|Wrap|Line Numbers
  1. <?
  2. $hostname="localhost";
  3. $username="";
  4. $password="";
  5. $dbname="";
  6. ?>
  7.  
Attached Files
File Type: zip bytes-test.zip (3.6 KB, 84 views)
Jul 27 '09 #33
As much as I would love to tell you that worked....it didn't! Sorry!

This is the error I got:

Notice: Undefined index: memberID in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 6

Notice: Undefined index: institution in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 7

Notice: Undefined index: address1 in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 8

Notice: Undefined index: address2 in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 9

Notice: Undefined index: contactName in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 14

Notice: Undefined index: position in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 15

Notice: Undefined index: phone in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 16

Notice: Undefined index: email in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 17

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/m/i/d/mideasthonors/html/addmember_db.php:1) in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 30

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/addmember_db.php:1) in /home/content/m/i/d/mideasthonors/html/addmember_db.php on line 32

This is what is in that file:
Expand|Select|Wrap|Line Numbers
  1. <? error_reporting(E_ALL);
  2.  
  3. include ("admintasks-dbcon.php");
  4.  
  5.  
  6. $memberID = $_POST['memberID'];
  7. $institution = $_POST['institution'];
  8. $address1 = $_POST['address1']; 
  9. $address2 = $_POST['address2'];
  10. $city = $_POST['city'];
  11. $state = $_POST['state'];
  12. $zipCode = $_POST['zip'];
  13. $website = $_POST['website'];
  14. $contactName = $_POST['contactName'];
  15. $position = $_POST['position'];
  16. $phoneNumber = $_POST['phone'];
  17. $email = $_POST['email'];
  18.  
  19. // OPEN CONNECTION ---> 
  20. mysql_connect($hostname,$username,$password);
  21. @mysql_select_db($dbname) or die( "Unable to select database");
  22.  
  23.  
  24.  $sql = "SELECT * FROM addMember WHERE email = '{$email}'";
  25.  $res = mysql_query( $sql ) or die( mysql_error );
  26.  
  27.  if ( mysql_num_rows( $res ) > 0 )
  28.  { 
  29.  
  30. session_start();
  31. $_SESSION["contactName"] = $contactName;
  32. header("location:alreadyMember.php");
  33.  
  34.  }
  35.  else{
  36.  
  37.  $query="INSERT addMember (
  38.  
  39.              memberID,    
  40.              institution,
  41.              address1,
  42.              address2,
  43.              city, 
  44.              state, 
  45.              zip, 
  46.              website, 
  47.              contactName, 
  48.              position, 
  49.              phoneNumber, 
  50.              email)
  51.  
  52.  VALUES (    '".$memberID."',
  53.              '".$institution."',
  54.              '".$address1."',
  55.              '".$address2."',
  56.              '".$city."',
  57.              '".$state."',
  58.              '".$zipCode."',
  59.              '".$website."',
  60.              '".$contactName."',
  61.              '".$position."',
  62.              '".$phoneNumber."',
  63.              '".$email."')";
  64.  
  65. $result=mysql_query($query) or die("Error in query:".mysql_error()); 
  66.  
  67. session_start();
  68. $_SESSION["contactName"] = $contactName;
  69. header("location:thankyouforbecomingamember.php");
  70. }
  71.  
  72. mysql_close();
  73. // CLOSE CONNECTION --->
  74. ?>
  75.  
Jul 28 '09 #34
Dormilich
8,658 Expert Mod 8TB
if there's no post (aka $_POST is empty) there will be no indexes to access giving you these errors.

the header error is a direct result of the previous error messages, no need to worry now.
Jul 28 '09 #35
so something is wrong with my header is what you are telling me???
Jul 28 '09 #36
Dormilich
8,658 Expert Mod 8TB
@mideastgirl
nope, just the opposite. the error messages about "undefined index" (which counts as output) cause your header function to throw out these header errors.
Jul 28 '09 #37
oh. What can I do to fix that???
Jul 28 '09 #38
Dormilich
8,658 Expert Mod 8TB
@mideastgirl
fix the other errors
Jul 28 '09 #39
oh you are so vague! Ok so I would go about fixing the undefined indexes HOW!!!!!
Jul 28 '09 #40
anfetienne
424 256MB
you might be getting the errors because you haven't changed the names in your form therefore its not populating the $_POST.

i gave you complete files from the form to sql....and i also gave a link to show exactly how it works. everything starts with the form so check to make sure the field names corresponding to the errored $_POST are correctly named the same as the $_POST.

http://theauctionwinners.com/test/

download the attachment from my post and just copy all files.....rename them as you wish but there is no need to change the coding. but the must do is import the sql.

let me know and send a test link when you have done that
Jul 28 '09 #41
Dormilich
8,658 Expert Mod 8TB
@mideastgirl
am I? I'd consider my answers rather clear, though I try to point you in the direction of the solution rather than posting code.

btw, programming does require thinking* (though a logical mind helps a lot). copy & paste won't get you too far.

* - compare it to games (say, chess). you don't become a master without effort. you have to play over and over again.
Jul 28 '09 #42
anfetienne
424 256MB
i wouldn't go as far as calling dorm vague....he is right and he has a big point.....i posted my test codes which work 100% which you can see at the link i've given twice but you changed parts of the coding and have got errors again.

i don't know exactly why you got the errors but its because the $_POST weren't being populated and that logically means its a form error....the same as you had before by not using the correct names in your php that you had on your form. i corrected this and gave you everything but you haven't followed it and changed it.

so to advise you go back to the form and double check the names. post a link to your test so we can see it please
Jul 28 '09 #43
I am not sure how to post a link to my test, and I did not change anything from your code. The only portion I changed was the thank you name of the php.
Jul 28 '09 #44
anfetienne
424 256MB
did you use the form i changed and did you import the sql file to your database?
Jul 28 '09 #45
Yes I did both of those things! The actual form that it needs to work off of is at http://mideasthonors.org/addmember.php so I cannot change that form! But the php coding is in the addMember.php page you instructed me to use. I also uploaded the table into SQL.
Jul 28 '09 #46
anfetienne
424 256MB
if thats the form that is being used and not the one i gave you then you need to change the names within the $_POST to correspond with the field names from the form i.e.

name
address_1
address_2
city
state
zip
website
contact_name
contact_position
contact_phone
contact_email

there is no need so change any variable names you just change what is in the postvar i.e.

$_POST['changeMe']
Jul 28 '09 #47
Do I also need to change everything in the sql as well?? Everything is still the same that is on the page that you gave me except the error: error_reporting(E_ALL); at the top. Its just that they need to enter their information from mideasthonors.org/addmember.php instead of addmembererror.php. Does that make sense??? I mean the same form is on both pages, just at the top it states that information was not filled in accurately.
Jul 28 '09 #48
hi all, I've got a problem with a script...
I need, through a vbscript, to move a 3parth win32 application to 0,0 (x,y) coordination of my desktop.
I know there is the "SetWindowPos" function in user32.dll API, maybe that what I need, but:

BOOL SetWindowPos(
HWND hWnd,
HWND hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
UINT uFlags
);

I don't have the parameters to pass, I do not have the handle to that window and I don't know how to get the others...
I can call it by:
"run32.exe user32dll,SetWindowPos hwnd,hWndInsertAfter,x,y,cx,cy,wFlags"
I found my window by this trick but is not useful to me:

set wsh=wscript.createobject("wscript.shell")
do
w = wsh.appactivate ("Found New Hardware Wizard")
if w then 'FOUND IT
loop while t<10000

And...
after that I have to add a vertical and an horizontal scroll bar...
Too much for me...
Could you please help me?
Is that the right way to do it?
Any comment will be appreciate.
Thanks,
Jul 28 '09 #49
anfetienne
424 256MB
no....as the sql i made for you works with the variables that were set from each $_POST all that needs to be changed is the names within the $_POST vars as they still append to those variables set to use in the sql query
Jul 28 '09 #50

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: danaf | last post by:
Dear all, (1)Is it possible to host PHP-based Web Portal + MySQL Database (e.g. PHPNuke) on MS Windows System? If yes which server software I need? (2)Compare PHP over JSP/ASP/CGI in...
12
by: jacob nikom | last post by:
Hi, I would like to store XML files in MySQL. What is the best solution: 1. Convert it to string and store it as CLOB/text 2. Serialize it and store as byte array 3. Flatten it out and create...
6
by: news | last post by:
I need some concise, easy to grok examples of what .Net (preferably C#.Net) has over just using old ASP or PHP with JavaScript. See, I'm a PHP guy, and while I started server-side scripting with...
7
by: John Paul | last post by:
I'm thinking of building an e-commerce site in php. Anyone got any advice in building one? What is the best way to implement a payment system? Are any legal issues involved? Thanks,
9
by: Paul | last post by:
I have a process that I want to speed up. It first was written in Microsoft Access then converted to VB.NET. I would like to hear some suggestions on how to speed it up. The process is to match...
3
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
4
by: hott5hotj | last post by:
I am trying to create an authentication using flash and AS3 as the underlying code using PHP as the server side scripting and mySQL to store the passwords. As I am a newbie I decided to start...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.