Jump to content

SalientAnimal

Members
  • Posts

    366
  • Joined

  • Last visited

Everything posted by SalientAnimal

  1. It was the only solution I could get to work for what I needed to do.
  2. Managed to solve this with a very basic change on my form rather than the submit part of the page. I just did this: <!-- INCLUDED A HIDDEN FIELD TO SET THE DEFAULT FORM VALUE OF THE CHECKBOX TO "EMPTY" --> <input type="hidden" name="handset" value=""> <input type="checkbox" name="handset" value="Handset">Handset
  3. Thanks, I think I was appling the if(isset incorrectly. So just to be sure, I would prefer to leave it blank if the checkbox is not set can I have it as follows: if(isset($_POST['accessory'])){ //code for when this checkbox is checked }else{ ($_POST['']) // code for when this checkbox is not checked Then, lastly, where in my submit for do I put this part of code?
  4. Hi All, I have included an image that will hopefully show what I am trying to achieve:
  5. Mmmm... I don't think I'm explaining it properly, but also don't know how to. And then again I also don't want to go and type a long message that no one will read trying to explain it. I can maybe try do a flow diagram in word/excel if that will help explain it?
  6. I never had that part of the code in my script at all. It was suggested that I add if(isset($_POST['accessory'])}$_POST['accessory'] == 'Accessory')else{$_POST['N/A']}; This is the original submit page: <?php $con = mysql_connect("localhost","user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("store", $con); $sql="INSERT INTO store_traffic (username , gender , ethnic_group , age_group , requirement , visit_detail , accessory , airtime , handset , postpaid , prepaid , handset_make) VALUES ('$_POST[username]' ,'$_POST[gender]' ,'$_POST[ethnic_group]' ,'$_POST[age_group]' ,'$_POST[requirement]' ,'$_POST[visit_detail]' ,'$_POST[accessory]' ,'$_POST[airtime]' ,'$_POST[handset]' ,'$_POST[postpaid]' ,'$_POST[prepaid]' ,'$_POST[handset_make]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; include "redirect_store.html"; mysql_close($con) ?>
  7. Currently when I submit my form I get an undefined index error message. What I am trying to do is to prevent this message from coming up. The error message occurs when the user has't checked the checkboxes.
  8. Ok so I tried using it like this: if(isset($_POST['accessory']) } $_POST['accessory'] == 'Accessory') else { $_POST['N/A'] }; But get this error: Parse error: syntax error, unexpected '}' (T_VARIABLE) in submit_store.php on line 14
  9. I can easily delete it, I'm just not sure how to have the data written to those other columns from the submit script, rather writing to the visit_detail column. The drop-down needs to be there, as it defines a whole lot of dynamic drop-downs, but the check boxes are also required, as there might be additional reasons for the visit.
  10. Here is a document with a description. Hope it explains better. visit.doc
  11. I'm not sure how to explain it, but its not an update function it a new entry being written to the database each time the user clicks submit. Maybe this table will explain it better? Ok the table didn't work, so I had to remove the comment. Let me send you an attachment
  12. How do I fix it? I can always rely on a reply from you
  13. Hi All, I have a PHP form that submits data to the database table. Everything is working however, for the purpose of having a better structure in the table I would like to make a change. On one part of the form the user would select a Visit Reason. If the user selects Sale they are given the "Primary" sales reasons from a dynamic drop-down box. As a sale can contain more than one type of sale e.g handset/accessory I have also added additional tick boxes to add any additional items that may for part of that sale. Currently the "Primary" sale reason is writing to one column in my table, and then each of the tick boxes will also write to their own individual boxes. What this means is Accessory can be written as the primary reason, and then again in its own field in the table. How can I get each of the fields from the drop-down to write to their individual table fields rather than have an additional field? Also, is it able to activate the radio buttons only if sale is selected from the drop-down? Here is submit code below: <?php$con = mysql_connect("localhost","username","password"); if (!$con) {die('Could not connect: ' . mysql_error()); } mysql_select_db("store", $con); $sql="INSERT INTO store_traffic (username , gender , ethnic_group , age_group , requirement , visit_detail , accessory , airtime , handset , postpaid , prepaid , handset_make) VALUES ('$_POST[username]' ,'$_POST[gender]' ,'$_POST[ethnic_group]' ,'$_POST[age_group]' ,'$_POST[requirement]' ,'$_POST[visit_detail]' ,'$_POST[accessory]' ,'$_POST[airtime]' ,'$_POST[handset]' ,'$_POST[postpaid]' ,'$_POST[prepaid]' ,'$_POST[handset_make]')"; if (!mysql_query($sql,$con)) {die('Error: ' . mysql_error()); } echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; include "redirect_store.html";mysql_close($con)?>
  14. Hi All, Can anyone tell me why I am getting an undefined index error message when submitting my form? This is happening only when the tick boxes are not selected, everything is working fine and the information is written to the database as required. Thanks, Here is my checkbox code: <table width="100%" border="0" align="center"> <tr> <td align="right" width="40%"><strong>Additional Visit Reasons :</strong></td> <td width="10%"><input type="checkbox" name="accessory" value="Accessory">Accessory</td> <td width="10%"><input type="checkbox" name="airtime" value="Airtime">Airtime</td> <td width="40%"><input type="checkbox" name="handset" value="Handset">Handset</td> </tr> </table>
  15. Hi All, I have a PHP form that submits data to the database table. Everything is working however, for the purpose of having a better structure in the table I would like to make a change. On one part of the form the user would select a Visit Reason. If the user selects Sale they are given the "Primary" sales reasons from a dynamic drop-down box. As a sale can contain more than one type of sale e.g handset/accessory I have also added additional tick boxes to add any additional items that may for part of that sale. Currently the "Primary" sale reason is writing to one column in my table, and then each of the tick boxes will also write to their own individual boxes. What this means is Accessory can be written as the primary reason, and then again in its own field in the table. How can I get each of the fields from the drop-down to write to their individual table fields rather than have an additional field? Also, is it able to activate the radio buttons only if sale is selected from the drop-down? Here is my code below: Form Page: <!-- USERNAME IS CAPTURED TO TRACK WHICH USER IS CAPTURING THE REQUESTS --> </td> <td><input type="hidden" name="username" value="<?php echo "$username"; ?>"></td> </tr> <!-- INITIATOR E-MAIL ADDRESS RETRIEVAL - THIS FIELD CAN BE USED TO CAPTURE THE USER'S E-MAIL ADDRESS --> <input type="hidden" name="email" readonly value="<?php echo $userinfo['email'];?>"> <!-- RANDOM REFERENCE NUMBER - THIS FIELD CAN BE USED TO PROVIDE THE USER WITH A REFERENCE NUMBER --> <!-- <tr> <!-- <td width="34%" align="right"><strong>Reference Number :</strong></td> --> <!-- <td> --> <input type="hidden" name="reference" readonly style="background-color: silver; color:#8B0000"> <!-- </td> --> <!-- </tr> --> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CUSTOMER SEX SELECTION - RADIO BUTTON OPTION USED LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="40%"><strong>Gender :</strong></td> <td width="10%"><input type="radio" name="gender" value="Female">Female</td> <td width="10%"><input type="radio" name="gender" value="Male">Male</td> <td width="40%"></td> </tr> </table> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CUSTOMER ETHNIC GROUP SELECTION - DROP-DOWN OPTION USED LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td width="40%" align="right" valign="middle"><strong>Ethnic Group :</strong></td> <td width="30%" align="left" valign="middle"><select name="ethnic_group" id="ethnic_group"> <option value=""> --- Select an Option --- </option> <option value="African">African</option> <option value="Asian">Asian</option> <option value="Coloured">Coloured</option> <option value="White">White</option> </select></td> <td width="30%"> </td> </tr> </table> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CUSTOMER AGE GROUP SELECTION - DROP-DOWN OPTION USED LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td width="40%" align="right" valign="middle"><strong>Age Group :</strong></td> <td width="30%" align="left" valign="middle"><select name="age_group" id="age_group"> <option value=""> --- Select an Option --- </option> <option value="< 18">< 18</option> <option value="18 - 25">18 - 25</option> <option value="26 - 35">26 - 35</option> <option value="36 - 45">36 - 45</option> <option value="46 - 55">46 - 55</option> <option value="56 - 65">56 - 65</option> <option value="65 +">65 +</option> </select></td> <td width="30%"> </td> </tr> </table> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CUSTOMER REASON FOR VISITING STORE TIER 1 - DROP-DOWN OPTION USED LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td width="40%" align="right" valign="middle"><strong>Reason For Customer's Visit :</strong></td> <td width="30%" align="left" valign="middle"><select name="requirement" id="category" onchange="javascript: listboxchange1(this.options[this.selectedIndex].value);"> <option value=""> --- Select an Option --- </option> <?php while ($requirement = mysql_fetch_array($result2)){ ?> <option value="<?php echo $requirement['requirement']; ?>"><?php echo $requirement['requirement'];?></option> <?php } ?> </select></td> <td width="30%"> </td> </tr> </table> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CUSTOMER REASON FOR VISITING STORE TIER 2 PRIMARY - DYNAMIC DROP-DOWN OPTION USED LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td width="40%" align="right" valign="middle"><strong>Reason Details :</strong></td> <td width="15%" ="left" valign="middle"><script name="visit_detail" id="visit_detail" type="text/javascript" language="javascript"> document.write('<select name="visit_detail" onchange="javascript: listboxchange2(this.options[this.selectedIndex].value);"><option value="">--- Select an Option ---</option></select>') </script></td> <td width="10%" align="right" valign="middle"><strong>Handset Make :</strong></td> <td width="35%" ="left" valign="middle"><script name="handset_make" id="handset_make" type="text/javascript" language="javascript"> document.write('<select name="handset_make" onchange="javascript: listboxchange3(this.options[this.selectedIndex].value);"><option value="">--- Select an Option ---</option></select>') </script></td> </tr> </table> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CUSTOMER REQUIREMENTS PART 2 - CHECK BOX OPTION USED LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="40%"><strong>Additional Visit Reasons :</strong></td> <td width="10%"><input type="checkbox" name="accessory" value="Accessory">Accessory</td> <td width="10%"><input type="checkbox" name="airtime" value="Airtime">Airtime</td> <td width="40%"><input type="checkbox" name="handset" value="Handset">Handset</td> </tr> <tr> <td width="40%"></td> <td width="10%"><input type="checkbox" name="postpaid" value="Postpaid">Postpaid</td> <td width="10%"><input type="checkbox" name="prepaid" value="Prepaid">Prepaid</td> <td width="40%"></td> </tr> </table> <!-- EMPTY TABLE USED FOR FIELD SPACING - LAST UPDATED ON 2012/10/17 --> <table width="100%" border="0" align="center"> <tr> <td align="right" width="100%"><br></td> </tr> </table> <!-- CLOSING TABLE TAGS TO END FORM LAYOUT --> </table> <!-- SUBMIT BUTTON FUNCTION --> <!-- OPENING TABLE TAGS TO OPEN SUBMIT BUTTON LAYOUT --> <br> <br> <table width="100%" align="center" border="0"> <tr> <td width="25%" align="center"></td> <td width="25%" align="center"><input type="submit" value="Submit" name="submit"></td> <td width="25%" align="center"><input type="reset" value="Reset Form" name="reset"></td> <td width="25%" align="center"></td> </tr> <!-- CLOSING TABLE TAGS TO CLOSE SUBMIT BUTTON LAYOUT --> </table> <!-- CLOSING FORM TAG TO CLOSE FORM --> </form> </html> Submit page: <?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("store", $con); $sql="INSERT INTO store_traffic (username , gender , ethnic_group , age_group , requirement , visit_detail , accessory , airtime , handset , postpaid , prepaid , handset_make) VALUES ('$_POST[username]' ,'$_POST[gender]' ,'$_POST[ethnic_group]' ,'$_POST[age_group]' ,'$_POST[requirement]' ,'$_POST[visit_detail]' ,'$_POST[accessory]' ,'$_POST[airtime]' ,'$_POST[handset]' ,'$_POST[postpaid]' ,'$_POST[prepaid]' ,'$_POST[handset_make]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; include "redirect_store.html"; mysql_close($con) ?>
  16. Hi All, For the last year or so I have been using the following code for my dynamic mutiple tier drop-down list: function listboxchange10(p_index) { //Clear Current options in Suburb List document.form1.suburb.length = 0; document.form1.suburb.options[0] = new Option("",""); switch (p_index) { //START OF SUBURB SELECTION LIST// case "Eastern Cape": document.form1.suburb.options[0] = new Option("",""); document.form1.suburb.options[1] = new Option("Amabhele","Amabhele"); document.form1.suburb.options[2] = new Option("Amacwera","Amacwera"); document.form1.suburb.options[3] = new Option("Amadiba","Amadiba"); break; case "Free-State": document.form1.suburb.options[0] = new Option("",""); document.form1.suburb.options[1] = new Option("Baralong Boo Moroka","Baralong Boo Moroka"); document.form1.suburb.options[2] = new Option("Bethlehem","Bethlehem"); document.form1.suburb.options[3] = new Option("Bloemfontein","Bloemfontein"); break; This was the only method at the time that I could find the allowed for more than two fields in the dynamic drop-down. I have used upto 5 dynamic drop-downs. However I now feel that this may have become a little outdated and it doesn't really give a lot of flexability. Problems I have found: Can't really customize the size of the drop-down boxes - these size dynamically as per the data in the box. When on tier 2 as an example, and there is no tier 3 option the drop-down menu can't pre-populate a N/A value, thus allowing for a field selection validation. Can anyone suggest a better method to use for a dynamic list?
  17. I have just been given another challenge and am probably going to post a question on the forums again, because quite honestly I have no idea where to start. But I know people dislike you posting if you have no code at all. Maybe you know where I can start? There's basically two things I wanna achieve here: 1. Create a Report Page (Not sure how to make this "Fancy") I want the user to select a date range using a calendar input, and then click on submit. It should then extract the data from the MySQL database to an excel file. (Writing the actual select query I am ok with) 2. To automate an extract from the database. Everyday, at say 06h00 a query should run, to extract current month to date data from the MySQL database, attach it an e-mail it. Any help is greatly appreciated.
  18. Ok so I have managed to get a bit of a solution to this, now I am left with another issue though. SELECT COUNT(*) , field1 , field2 FROM tablename WHERE field1 like '%TEXTSTRING%' OR field1 like '%ANOTHERTEXTSTRING%' GROUP BY CASE WHEN field1 like [color=red]'%TEXTSTRING%'[/color] THEN [color=red]'GROUPING 1'[/color] WHEN field1 like [color=red]'%TEXTSTRINGSIMILARTO1%' [/color] THEN [color=red]'GROUPING 1'[/color] WHEN field1 like [color=red]'%ANOTHERTEXTSTRING%'[/color] THEN[color=red] 'GROUPING 2[/color]ELSE NULL END What I need to do now is display the renamed field value instead of the exsting field value.
  19. Hi Guys/Gals, Is it possible to perform a Group By (Part of String)? Basically, I have a query where in my WHERE CLAUSE I have the LIKE statement. I am then grouping by a few fields and would like one of the GROUPs to be parts of the WHERE. EG. SELECT COUNT(*) , field1 , field2 FROM tablename WHERE field1 like '%TEXTSTRING%' OR field1 like '%ANOTHERTEXTSTRING%' GROUP BY (And this is where I don't know how to GROUP BY '%TEXTSTRING%' and '%ANOTHERTEXTSTRING%'
  20. Thanks guys, I managed to solve this by using a CONCAT(FIELD,"\t").
  21. Hi All, My quest is pretty simple, but I haven't been able to find a solution. I'm trying to extract a BIGINT value of 13 characters with my query. Everytime this number is exported to Excel in CSV from MySQL Workbench the number is not displayde correctly in the cells and you first need to format the cell. Is there a way to run the query so that the conversion happens before exporting to Excel CSV?
  22. I don't want to mark it as solved yet, just encase my data isn't always being written to the database just yet.
  23. Ok so it worked when removing the tags. Why did we put them in there in first place? Sorry I don't mean this question in sarcastic manner as I know it may seem like that, I'm asking for my understanding. The only thing to test now is to be sure that everything is being written to the database table before the user gets the e-mail. Here is the working code for anyone that might want it: <?php ini_set("display_errors", 1); error_reporting(-1); if(isset($_POST['status']) && ($_POST['status']) == 'Active') { //Connect to DB server $con = mysql_connect("localhost","root","password") or die("Could not connect: ".mysql_error()); $db = mysql_select_db("database", $con) or die("Could not select database: ".mysql_error()); $sql="INSERT INTO userinfo (username , password , title , champ , race , sex , account_manager , department , designation , direct_report , id_number , number , alt_number , email , domain , next_of_kin , next_of_kin_number , status ) VALUES ('$_POST[username]' , '$_POST[password]' , '$_POST[title]' , '$_POST[fname] $_POST[lname]' , '$_POST[race]' , '$_POST[sex]' , '$_POST[account_manager]' , '$_POST[department]' , '$_POST[designation]' , '$_POST[direct_report]' , '$_POST[id_number]' , '$_POST[number]' , '$_POST[alt_number]' , '$_POST[email]' , '$_POST[domain]' , '$_POST[kin_fname] $_POST[kin_lname]' , '$_POST[next_of_kin_number]' , '$_POST[status]' )"; //Execute query $result = mysql_query($sql); if($result) { //Create email variable $to = "$_POST[email]"; $subject = "Registration for $_POST[username]"; $message = " Hi $_POST[fname] Thank you for completing your registration on the Call Tracker. You have registered using the following details: Username: $_POST[username] Password: $_POST[password] Name & Surname: $_POST[fname] $_POST[lname] E-Mail: $_POST[email] Should any of this information be incorrect, please contact the Administrator. Welcome Aboard"; //Send email mail($to, $subject, $message); echo "<b><font color='white' face='segoe ui' size='2' align='center'>Congratulations you are registered!</b></font>"; include "redirect_register.html"; } else { echo "Error: ".mysql_error(); } } else { echo "Error: ".mysql_error(); } ?>
  24. Hi mikosiko, Yip, it is all the code. In one of my more recent posts on this thread, Lily had requested to see the form code as well which I then included. I have the . This was used as one of the very first recommendations on this thread. (Had to modify the email tag here as it links it. I didn't know it does that :-), so intentionally added and extra space). I really do appreciate everyone's input.
×
×
  • Create New...

Important Information

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