Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Posts posted by mikebyrne

  1. Hi I can get my records to display but Id like a checkbox to appear with every record. Can I incorporate this into my loop or will i have to display the results in a set table format and place the checkbox within this??

     

    My code is:

     

    <?php
    // let's get some data
    include('adminconnect.php');
    $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = DATE_FORMAT(now(),'%y/%m/%d')");
    while( $row = mysql_fetch_array($sql) ) {
    // loop through and display
    ?>
    
    <tr align="left">
    <td width="33"> </td>
    <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td>
    <td width="61"><?php echo $row['Orderdate'];?></td>
    <td width="61"><?php echo $row['Dispatchdate'];?></td>
    <td width="230"><?php echo $row['Custname'];?></td>
    <td width="170"><?php echo $row['Trackno'];?></td>
    <td width="56" align="right"><?php echo $row['Amount'];?></td>
    <td width="21"> </td>
    <td width="136">test</td>
    </tr>
    
    
    <?
    }
    ?>
    </table>
    

     

     

  2. I tried that before but I'm getting an error

     

     

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Admin_files\New.php on line 210

     

    Line 210 refers to

     

    //loop through records
    

     

    so i assume the line above it is the problem

     

  3. I want my program to list all orders that have been procesed today.

     

    At present my code looks like

     

    <table width="850" border="0" cellspacing="0" cellpadding="0">
    <?php
    // let's get some data
    include('adminconnect.php');
    $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = 01/22/08");
    while( $row = mysql_fetch_array($sql) ) {
    // loop through and display
    ?>
    
    <tr align="left">
    <td width="33"> </td>
    <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td>
    <td width="61"><?php echo $row['Orderdate'];?></td>
    <td width="61"><?php echo $row['Dispatchdate'];?></td>
    <td width="230"><?php echo $row['Custname'];?></td>
    <td width="170"><?php echo $row['Trackno'];?></td>
    <td width="56" align="right"><?php echo $row['Amount'];?></td>
    <td width="21"> </td>
    <td width="136">test</td>
    </tr>
    
    
    <?
    }
    ?>
    </table>
    

     

    Is the a varible that will automatically assign todays date so I wont have to keep changing the date??

     

    Also the date fields are in US Format in my database so that will make a difference

     

  4. I would like to put my dotted line after every record produced in the loop. At the minute I can put it at the start and the end.

     

    How can i place the code so it is displayed after every record?

     

     

    <?php
    // let's get some data
    include('adminconnect.php');
    $sql = mysql_query("SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1");
    while( $row = mysql_fetch_array($sql) ) {
    // loop through and display
    ?>
    
    <tr align="left">
    <td width="33"> </td>
    <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td>
    <td width="61"><?php echo $row['Orderdate'];?></td>
    <td width="61"><?php echo $row['Dispatchdate'];?></td>
    <td width="230"><?php echo $row['Custname'];?></td>
    <td width="170"><?php echo $row['Trackno'];?></td>
    <td width="56" align="right"><?php echo $row['Amount'];?></td>
    <td width="21"> </td>
    <td width="136">test</td>
    </tr>
    
    
    <?
    }
    ?>
    </table>
    

     

    My html for the line is:

     

                    <div class="clr"><!-- --></div>
    	<div class="padTop11"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div id="dottedIn"><!-- --></div>
    	<div class="clr"><!-- --></div>
    

     

  5. my test code is now:

     

    <?php
    
    include('adminconnect.php');
    
    $sql = mysql_query("SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1");
    
    while( $row = mysql_fetch_array($sql) )
    {
    
    echo "<table>";
    echo "<tr>";
    echo "<td>" . $row['OrderNo'] . "</td>";
    echo "<td>" . $row['Custname'] . "</td>";
    echo "</tr>";
    echo "</table>";
    
    
    }
    
    
    ?>
    
    <!-- data start -->
    	<div class="padTop11"><!-- --></div>
    
    	<div class="clr"><!-- --></div>
    	<div class="padTop1">
    		<table width="850" border="0" cellspacing="0" cellpadding="0">
    			<tr align="left">
    				<td width="33"> </td>
    				<td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black">1231488425</a></td>
    				<td width="61">05/20/06</td>
    				<td width="61">05/20/06</td>
    
    				<td width="230">. $row['OrderNo'] .</td>
    				<td width="170">. $row['TrackNo'] .</td>
    				<td width="56" align="right">. $row['Amount'] .</td>
    				<td width="21"> </td>
    				<td width="136">test</td>
    			</tr>
    		</table>
    
    	</div>
    	<div class="clr"><!-- --></div>
    	<div class="padTop11"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div id="dottedIn"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<!-- data finish -->
    

     

    My results are:

     

    34556 rob

      1231488425 05/20/06 05/20/06 . $row['OrderNo'] . . $row['TrackNo'] . . $row['Amount'] .   test

     

     

     

    . $row['OrderNo'] . . $row['TrackNo'] . . $row['Amount'] .  are not showing there contents, how do I change this?

  6. Great got a test page working!! Now to add it to my template page

     

    I have the figures typed out and styled already. Is it just a matter of replacing the figures with the varible name?

     

    <!-- data start -->
    	<div class="padTop11"><!-- --></div>
    
    	<div class="clr"><!-- --></div>
    	<div class="padTop1">
    		<table width="850" border="0" cellspacing="0" cellpadding="0">
    			<tr align="left">
    				<td width="33"> </td>
    				<td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black">1231488425</a></td>
    				<td width="61">05/20/06</td>
    				<td width="61">05/20/06</td>
    
    				<td width="230">Hanae Kaorida </td>
    				<td width="170">US POSTAL 3103855588</td>
    				<td width="56" align="right">$107.00</td>
    				<td width="21"> </td>
    				<td width="136">Ground</td>
    			</tr>
    		</table>
    
    	</div>
    	<div class="clr"><!-- --></div>
    	<div class="padTop11"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div id="dottedIn"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<!-- data finish -->
    

     

    Would, for example Hanae Kaorida become . $row['Custname'] .    ?????

     

     

    Also where do I place the new php code in my already written template??

  7. I'm going to run a test to get the figures from the db. Would this work??

     

    <?php
    
    include('adminconnect');
    
    
    // table name
    $tbl_name= "admin";
    
    $sql= SELECT OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet FROM admin WHERE Ordercompleted = 1;
    
    // values sent from database
    $OrderNo=$_POST['OrderNo'];
    $Orderdate=$_POST['Orderdate'];
    $Custname=$_POST['Custname'];
    $Dispatchdate=$_POST['Dispatchdate'];
    $Trackno=$_POST['Trackno'];
    $Amount=$_POST['Amount'];
    $Shippingmet=$_POST['Shippingmet'];
    $Ordercompleted=$_POST['Ordercompleted'];
    
    
    $OrderNo = mysql_real_escape_string ($_POST['OrderNo']);
    $Orderdate = mysql_real_escape_string ($_POST['Orderdate']);
    $Custname = mysql_real_escape_string ($_POST['Custname']);
    $Trackno = mysql_real_escape_string ($_POST['Trackno']);
    $Amount = mysql_real_escape_string ($_POST['Amount']);
    $Shippingmet = mysql_real_escape_string ($_POST['Shippingmet']);
    $Ordercompleted = mysql_real_escape_string ($_POST['Ordercompleted']);
    
    Echo $OrderNo['OrderNo'] ;
    Echo $Orderdate['Orderdate'] ;
    
    
    }
    

     

     

  8. Im trying to get all my completed orders to appear in a table on my .php page.

     

    I'll need an If statement something like

     

    If (Ordercompleted == 1) show OrderNo, Orderdate, Dispatchdate, Custname, Trackno,  Amount, Shippingmet in a table

     

    My php page looks like this

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>e-commerce admin page sample | order</title>
    <link href="../Admin_files/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/JavaScript" src="../Admin_files/wrapper.js"></script>
    </head>
    <body>
    <div id="Box">
    
    <div id="logoBox"><a href="http://www.btrax.com/" target="_blank"><img src="../Admin_files/logo.gif" width="51" height="125" border="0" /></a></div>
    <div id="contentBox">
    <form>
    
    
    <!-- logo start -->
    <div id="container">
    	<div class="padTop28"><!-- --></div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    
    <!-- logo finish -->
    
    
    
    <!-- menu start -->
    <div id="container">
    			<div id="menu1">
    		<div id="menu_on"><!-- --></div>
    		<div id="menu_text_on"><a href="../order/new.php" class="black_on">Order</a></div>
    
    		<div id="menu_space1"><!-- --></div>
    		<div id="menu_off"><!-- --></div>
    		<div id="menu_text_off"><a href="../sales/sales.php" class="black">Sales</a></div>
    		<div id="menu_space1"><!-- --></div>
    
    		<div id="menu_off"><!-- --></div>
    		<div id="menu_text_off"><a href="../item/list.php" class="black">Edit item</a></div>
    		<div id="menu_space1"><!-- --></div>
    		<div id="menu_off"><!-- --></div>
    
    		<div id="menu_text_off"><a href="../shipping/current.php" class="black">Postage fee</a></div>
    		<div id="menu_space1"><!-- --></div>
    	</div>
    
    	<div class="clr"><!-- --></div>		<div class="clr"><!-- --></div>
    	<div class="padTop5"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div id="dotted"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div class="padTop5"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div id="menu2">
    
    		<div id="menu_hide"><!-- --></div>
    		<div id="menu_text_off"><a href="new.php" class="black">New orders</a></div>
    		<div id="menu_space2"><!-- --></div>
    		<div id="menu_text_off"><a href="Unprocessed.php" class="black">Unprocessed orders</a></div>
    		<div id="menu_space2"><!-- --></div>
    		<div id="menu_text_on"><a href="completed.php" class="black_on">Completed orders</a></div>
    		<div class="clr"><!-- --></div>
    
    	</div>
    	<div class="clr"><!-- --></div>
    	<div class="padTop38"><!-- --></div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <!-- menu finish -->
    
    
    
    <!-- top start -->
    <div id="container">
    
    	<div id="line"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <div id="containerBg1">
    	<div class="padTop15"><!-- --></div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <!-- top finish -->
    
    
    
    
    <!-- data title start -->
    <div id="containerBg2">
    	<div class="padTop2"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div class="titleBox">
    		<table width="850" border="0" cellspacing="0" cellpadding="0">
    			<tr align="left">
    				<td width="33"> </td>
    				<td width="82"><a href="#">order no.</a></td>
    
    				<td width="61"><a href="#">order date</a></td>
    				<td width="61"><a href="#">ship date</a></td>
    				<td width="230"><a href="#">customer name</a></td>
    				<td width="170"><a href="#">tracking no.</a></td>
    				<td width="56" align="right"><a href="#">amount</a></td>
    				<td width="21"> </td>
    
    				<td width="136"><a href="#">shipping method</a></td>
    		  </tr>
    	  </table>
    	</div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <!-- data title finish -->
    
    
    
    
    <!-- 1px space start -->
    <div id="containerBg1">
    	<div class="padTop1"><!-- --></div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <!-- 1px space finish -->
    
    
    
    <!-- data top start -->
    <div id="containerBg3">
    
    	<div class="padTop1"><!-- --></div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <!-- data top finish -->
    
    
    
    <!-- data content start -->
    <div id="containerBg4">
    
    
    	<!-- btn start -->
    	<div class="clr"><!-- --></div>
    
    	<div class="padTop100"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div id="btn_text">
    		 <a href="#"><< previous</a>
    		       
    		 <a href="#">1</a>
    		    
    
    		 <span class="textBlackB">2</span>
    		    
    		 <a href="#">3</a>
    		       
    		 <a href="#">next>></a> </div>
    	<div class="clr"><!-- --></div>
    	<div class="padTop16"><!-- --></div>
    
    	<div class="clr"><!-- --></div>
    	<!-- btn finish -->
    
    </div>
    <div class="clr"><!-- --></div>
    <!-- data content finish -->
    
    
    
    <!-- data btm start -->
    <div id="containerBg3">
    	<div class="padTop1"><!-- --></div>
    	<div class="clr"><!-- --></div>
    
    </div>
    <div class="clr"><!-- --></div>
    <!-- data btm finish -->
    
    
    
    <!-- btm start -->
    <div id="containerBg1">
    	<div class="padTop15"><!-- --></div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    
    <div id="container">
    	<div id="line"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <div class="padTop16"><!-- --></div>
    <div class="clr"><!-- --></div>
    <!-- btm finish -->
    
    </form>
    </div>
    
    </div>
    </body>
    </html>
    

     

    The table within the code looks like this

     

    <!-- data title start -->
    <div id="containerBg2">
    	<div class="padTop2"><!-- --></div>
    	<div class="clr"><!-- --></div>
    	<div class="titleBox">
    		<table width="850" border="0" cellspacing="0" cellpadding="0">
    			<tr align="left">
    				<td width="33"> </td>
    				<td width="82"><a href="#">order no.</a></td>
    
    				<td width="61"><a href="#">order date</a></td>
    				<td width="61"><a href="#">ship date</a></td>
    				<td width="230"><a href="#">customer name</a></td>
    				<td width="170"><a href="#">tracking no.</a></td>
    				<td width="56" align="right"><a href="#">amount</a></td>
    				<td width="21"> </td>
    
    				<td width="136"><a href="#">shipping method</a></td>
    		  </tr>
    	  </table>
    	</div>
    	<div class="clr"><!-- --></div>
    </div>
    <div class="clr"><!-- --></div>
    <!-- data title finish -->
    

     

    There is also a file that connects to the database called adminconnect.php so i guess that will also have to be placed within the code.

     

    Any help would be great!!

  9. I want my optionlist to point to my php pages. How can I code this??

     

    <html>
    <head>
    <title>Ass3</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
    <body bgcolor="#FFFF00">
    <form name="myform" action="Ass3.asp" method="POST">
    <div align="center">
      <p> </p>
      <p><font size="+7">Database Maintenance </font></p>
      <p> </p>
      <p> </p>
    
      <p>
        <select name="mydropdown" size="1">
          <option value="Select">Please Select Option</option>
          <option value="Add">Add a Project</option>
          <option value="Change">Change a Project</option>
          <option value="Delete">Delete a project</option>
          <option value="List">List all project details</option>
    
        </select>
              </p>
              <input type="submit" value="Go!">
    </div>
    </form>
    </body>
    </html>
    

     

    I want Add to bring me to Add.asp, change to Change.asp etc

  10. I want to vaidate the the age section so the user has to enter a numeric values only.

     

    What would the code be for that?

     

    <?php
    
    include('config1.php');
    
    
    // table name
    $tbl_name= "applications";
    
    // values sent from form
    $name=$_POST['name'];
    $age=$_POST['age'];
    $location=$_POST['location'];
    $mydropdown1=$_POST['mydropdown1'];
    $reason=$_POST['reason'];
    $mydropdown2=$_POST['mydropdown2'];
    
    $errorList = array();
    $name = mysql_real_escape_string ($_POST['name']);
    $age = mysql_real_escape_string ($_POST['age']);
    $location = mysql_real_escape_string ($_POST['location']);
    $mydropdown1 = mysql_real_escape_string ($_POST['mydropdown1']);
    $reason = mysql_real_escape_string ($_POST['reason']);
    $mydropdown2 = mysql_real_escape_string ($_POST['mydropdown2']);
    
    $which=$_POST['which'];
    
    if ($mydropdown2 == "YES") {
         if ($which == "") {
              echo "Error, you must enter which chatsite you work for";
    	  $errorList[] = 'Please enter the chatsite you worked for';
         }
    }
    
    
    if ($mydropdown1 == "Option") {
    echo "Please select what position your applying for";
    }
    
    if ($mydropdown2 == "Option1") {
    echo "Do you work for a Chatsite?";
    }
    
    if (trim ($sname) == "") {
    		$errorList[] = 'Invalid entry: Name';
    		echo "please enter your name";
    	}
    	if (trim ($age) == "") {
    		$errorList[] = 'Invalid entry: Age';
    		echo "please enter your Age";
    	}
    	if (trim ($location) == "") {
    		$errorList[] = 'Invalid entry: Location';
    		echo "please enter a location";
    	}
    	if (trim ($location) == "") {
    		$errorList[] = 'Invalid entry: Reason';
    		echo "please enter a reason";
    	}
    
    if (sizeof ($errorList) == 0) {
    //no errors, insert into db
    $sql="INSERT INTO $tbl_name (Username, Age, Location, Position, Reason, Workonsite, Whatsite) VALUES ('$name', '$age', '$location', '$mydropdown1', '$reason','$mydropdown2', '$which')";
    $result=mysql_query($sql)or die(mysql_error());
    }
    else {
    //errors, process errorList array
    }
    
    
    ?>
    

     

     

  11. <?php
    
    include('config1.php');
    
    
    // table name
    $tbl_name= "applications";
    
    // values sent from form
    $name=$_POST['name'];
    $age=$_POST['age'];
    $location=$_POST['location'];
    $mydropdown1=$_POST['mydropdown1'];
    $reason=$_POST['reason'];
    $mydropdown2=$_POST['mydropdown2'];
    
    $errorList = array();
    $name = mysql_real_escape_string ($_POST['name']);
    $age = mysql_real_escape_string ($_POST['age']);
    $location = mysql_real_escape_string ($_POST['location']);
    $mydropdown1 = mysql_real_escape_string ($_POST['mydropdown1']);
    $reason = mysql_real_escape_string ($_POST['reason']);
    $mydropdown2 = mysql_real_escape_string ($_POST['mydropdown2']);
    
    $which=$_POST['which'];
    
    if ($mydropdown2 == "YES") {
         if ($which == "") {
              echo "Error, you must enter which chatsite you work for";
    	  $errorList[] = 'Please enter the chatsite you worked for';
         }
    }
    
    
    if ($mydropdown1 == "Option") {
    echo "Please select what position your applying for";
    }
    
    if ($mydropdown2 == "Option1") {
    echo "Do you work for a Chatsite?";
    }
    
    if (trim ($sname) == "") {
    		$errorList[] = 'Invalid entry: Name';
    		echo "please enter your name";
    	}
    	if (trim ($age) == "") {
    		$errorList[] = 'Invalid entry: Age';
    		echo "please enter your Age";
    	}
    	if (trim ($location) == "") {
    		$errorList[] = 'Invalid entry: Location';
    		echo "please enter a location";
    	}
    	if (trim ($location) == "") {
    		$errorList[] = 'Invalid entry: Reason';
    		echo "please enter a reason";
    	}
    
    if (sizeof ($errorList) == 0) {
    //no errors, insert into db
    $sql="INSERT INTO $tbl_name (Username, Age, Location, Position, Reason, Workonsite, Whatsite) VALUES ('$name', '$age', '$location', '$mydropdown1', '$reason','$mydropdown2', '$which')";
    $result=mysql_query($sql)or die(mysql_error());
    }
    else {
    //errors, process errorList array
    }
    
    
    ?>
    
    

  12. Added one more

     

    <?php
    
    include('config1.php');
    
    
    // table name
    $tbl_name= "applications";
    
    // values sent from form
    $name=$_POST['name'];
    $age=$_POST['age'];
    $location=$_POST['location'];
    $mydropdown1=$_POST['mydropdown1'];
    $reason=$_POST['reason'];
    $mydropdown2=$_POST['mydropdown2'];
    
    $errorList = array();
    $name = mysql_real_escape_string ($_POST['name']);
    $age = mysql_real_escape_string ($_POST['age']);
    $location = mysql_real_escape_string ($_POST['location']);
    $mydropdown1 = mysql_real_escape_string ($_POST['mydropdown1']);
    $reason = mysql_real_escape_string ($_POST['reason']);
    $mydropdown2 = mysql_real_escape_string ($_POST['mydropdown2']);
    
    $which=$_POST['which'];
    
    if ($mydropdown2 == "YES") {
         if ($which == "") {
              echo "Error, you must enter which chatsite you work for";
    	  $errorList[] = 'Please enter the chatsite you worked for';
         }
    }
    
    
    if ($mydropdown1 == "Option") {
    echo "Please select what position your applying for";
    }
    
    if ($mydropdown2 == "Option1") {
    echo "Do you work for a Chatsite?";
    }
    
    if (sizeof ($errorList) == 0) {
    //no errors, insert into db
    $sql="INSERT INTO $tbl_name (Username, Age, Location, Position, Reason, Workonsite, Whatsite) VALUES ('$name', '$age', '$location', '$mydropdown1', '$reason','$mydropdown2', '$which')";
    $result=mysql_query($sql)or die(mysql_error());
    }
    else {
    //errors, process errorList array
    }
    
    
    ?>
    
    

  13. I've fixed the two listbox validations

     

    <?php
    
    include('config1.php');
    
    
    // table name
    $tbl_name= "applications";
    
    // values sent from form
    $name=$_POST['name'];
    $age=$_POST['age'];
    $location=$_POST['location'];
    $mydropdown1=$_POST['mydropdown1'];
    $reason=$_POST['reason'];
    $mydropdown2=$_POST['mydropdown2'];
    
    $errorList = array();
    $name = mysql_real_escape_string ($_POST['name']);
    $age = mysql_real_escape_string ($_POST['age']);
    $location = mysql_real_escape_string ($_POST['location']);
    $mydropdown1 = mysql_real_escape_string ($_POST['mydropdown1']);
    $reason = mysql_real_escape_string ($_POST['reason']);
    $mydropdown2 = mysql_real_escape_string ($_POST['mydropdown2']);
    
    $which=$_POST['which'];
    
    if ($mydropdown2 == "YES") {
         if ($which == "") {
              echo "Error, you must enter which chatsite you work for";
    	  $errorList[] = 'Please enter the chatsite you worked for';
         }
    }
    
    
    if ($mydropdown1 == "Option") {
    echo "Please select what position your applying for";
    }
    
    
    if (sizeof ($errorList) == 0) {
    //no errors, insert into db
    $sql="INSERT INTO $tbl_name (Username, Age, Location, Position, Reason, Workonsite, Whatsite) VALUES ('$name', '$age', '$location', '$mydropdown1', '$reason','$mydropdown2', '$which')";
    $result=mysql_query($sql)or die(mysql_error());
    }
    else {
    //errors, process errorList array
    }
    
    
    ?>
    

     

    What else should I do?

  14. <?php
    
    include('config1.php');
    
    
    // table name
    $tbl_name= "applications";
    
    // values sent from form
    $name=$_POST['name'];
    $age=$_POST['age'];
    $location=$_POST['location'];
    $mydropdown1=$_POST['mydropdown1'];
    $reason=$_POST['reason'];
    $mydropdown2=$_POST['mydropdown2'];
    
    $errorList = array();
    $name = mysql_real_escape_string ($_POST['name']);
    $age = mysql_real_escape_string ($_POST['age']);
    $location = mysql_real_escape_string ($_POST['location']);
    $mydropdown1 = mysql_real_escape_string ($_POST['mydropdown1']);
    $reason = mysql_real_escape_string ($_POST['reason']);
    $mydropdown2 = mysql_real_escape_string ($_POST['mydropdown2']);
    
    $which=$_POST['which'];
    
    if ($mydropdown2 == "YES") {
         if ($which == "") {
              echo "Error, you must enter which chatsite you work for";
    	  $errorList[] = 'Please enter the chatsite you worked for';
         }
    }
    else {
    echo "They picked NO";
    }
    
    
    
    if (errorlist == "Array") {
       echo "TEST";
    }
    else
    
    // Insert data into database
    $sql="INSERT INTO $tbl_name (Username, Age, Location, Position, Reason, Workonsite, Whatsite) VALUES ('$name', '$age', '$location', '$mydropdown1', '$reason','$mydropdown2', '$which')";
    $result=mysql_query($sql)or die(mysql_error());
    
    
    ?>
    
    

     

    My code still doesnt stop the data going into the database if the user selects Yes and doesnt input what site they work for.

     

    The error msg seems to work fine

×
×
  • 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.