Jump to content

antbates1991

Members
  • Posts

    26
  • Joined

  • Last visited

antbates1991's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. All that needed changing was $_SESSION["CustomerID"] ='$rowcustomer[CustomerID]'; to $_SESSION["Customer"] = $rowcustomer['CustomerID']; now it works fine.
  2. Wow, I'm only asking for a few pointers no need to be rude, and its goodbye.
  3. What would be the correct way of storing the data from value=$'rowcustomer[CustomerID]'; into a Session Var? Ive tried $_POST[$_SESSION["CustomerID"]] = '$rowcustomer[property[CustomerID]]'; and $_POST[$_SESSION["CustomerID"]] ='$rowcustomer[CustomerID]' and in print_r i get [] => $rowcustomer[property[CustomerID]] ) or [] => $rowcustomer[CustomerID] )
  4. I didn't know that. What would be the best way to save these values so I can use them later?
  5. OKay I see what you mean now. I've gotten rid of the GET array because it isn't doing anything. if (isset($_POST['editcustomerbtn'])) { $_POST['selectedCustomerIDS']; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "<br>"; foreach($_POST['selectedCustomerIDS'] as $CustomerIDforedit){ $theselectedrowcustomer = "SELECT * from CustomerTable WHERE CustomerID = '$CustomerIDforedit'"; $theselectedrowcustomerresults = mysql_query($theselectedrowcustomer); $rowcustomer = mysql_fetch_assoc($theselectedrowcustomerresults); $count = mysql_num_rows($theselectedrowcustomerresults); // thats the query I run to populate $rowcustomer } if ($count == 1) { // the values are then echoed out into this form and it is these I want to store. echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "You have selected the following details.<br>"; echo "<br>"; echo "<label for='CustomerID'>Customer ID*:</label><br>"; echo "<input id='CustomerID' type='text' maxlength='20' name='CustomerID' value='$rowcustomer[CustomerID]' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$rowcustomer[FirstName]' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$rowcustomer[SecondName]' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='PhoneNumber'>Phone Number*:</label><br>"; echo "<input id='PhoneNumber' type='tel' maxlength='11' name='PhoneNumber' value='$rowcustomer[PhoneNumber]' pattern='^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$' required readonly/><br>"; echo "<br>"; echo "<input id='addcustomertoviewing' type='submit' name='addcustomertoviewing' value='Add Customer' /><br>"; // This is how I'm a trying to store the value in each form field into a Variable. $CustomerID = $rowcustomer['CustomerID']; $FirstName = $rowcustomer['FirstName']; $SecondName = $rowcustomer['SecondName']; $PhoneNumber = $rowcustomer['PhoneNumber']; echo "</form>"; } }
  6. You're right I populate $rowcustomer using a query. The values are then placed into a form like this. This value shows up as it should. value='$rowcustomer[CustomerID]' I then take this value and place it into a variable using $CustomerID = $rowcustomer['CustomerID']; Or at least thats what I'm trying to do. Once I've done this I can then use the variable later on to echo the value out into the other form. What this the best way to do this as obviously something is wrong somewhere.
  7. Yeah here is the one for customer. They are all identical. foreach($_POST['selectedCustomerIDS'] as $CustomerIDforedit){ $theselectedrowcustomer = "SELECT * from CustomerTable WHERE CustomerID = '$CustomerIDforedit'"; $theselectedrowcustomerresults = mysql_query($theselectedrowcustomer); $rowcustomer = mysql_fetch_assoc($theselectedrowcustomerresults); $count = mysql_num_rows($theselectedrowcustomerresults); } if ($count == 1) { $CustomerID = $_GET['CustomerID']; $FirstName = $_GET['FirstName']; $SecondName = $_GET['SecondName']; $PhoneNumber = $_GET['PhoneNumber']; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "You have selected the following details.<br>"; echo "<br>"; echo "<label for='CustomerID'>Customer ID*:</label><br>"; echo "<input id='CustomerID' type='text' maxlength='20' name='CustomerID' value='$rowcustomer[CustomerID]' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$rowcustomer[FirstName]' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$rowcustomer[SecondName]' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='PhoneNumber'>Phone Number*:</label><br>"; echo "<input id='PhoneNumber' type='tel' maxlength='11' name='PhoneNumber' value='$rowcustomer[PhoneNumber]' pattern='^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$' required readonly/><br>"; echo "<br>"; echo "<input id='addcustomertoviewing' type='submit' name='addcustomertoviewing' value='Add Customer' /><br>"; $CustomerID = $rowcustomer['CustomerID']; $FirstName = $rowcustomer['FirstName']; $SecondName = $rowcustomer['SecondName']; $PhoneNumber = $rowcustomer['PhoneNumber']; echo "</form>"; } } if (isset($_POST['addcustomertoviewing'])) { $CustomerID = $_GET['CustomerID']; $FirstName = $_GET['FirstName']; $SecondName = $_GET['SecondName']; $PhoneNumber = $_GET['PhoneNumber']; $EmployeeID = $_GET['EmployeeID']; $EmpFirstName = $_GET['FirstName']; $EmpSecondName = $_GET['SecondName']; $ProductID = $_GET['ProductID']; $PostCode = $_GET['PostCode']; $PropertyName = $_GET['PropertyName']; { echo "Please add a date and time for the viewing.<br>"; echo "<br>"; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "<label for='CustomerID'>Customer ID*:</label><br>"; echo "<input id='CustomerID' type='text' maxlength='20' name='CustomerID' value='$CustomerID' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$FirstName' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$SecondName' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='PhoneNumber'>Phone Number*:</label><br>"; echo "<input id='PhoneNumber' type='tel' maxlength='11' name='PhoneNumber' value='$PhoneNumber' pattern='^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$' required readonly/><br>"; echo "<label for='EmployeeID'>Employee ID*:</label><br>"; echo "<input id='EmployeeID' type='text' maxlength='20' name='ProductID' value='$EmployeeID' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$EmpFirstName' readonly /><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$EmpSecondName' readonly /><br>"; echo "<label for='ProductID'>Property ID*:</label><br>"; echo "<input id='ProductID' type='text' maxlength='20' name='ProductID' value='$rowproperty[ProductID]' readonly /><br>"; echo "<label for='PropertyName'>Property Name*:</label><br>"; echo "<input id='PropertyName' type='text' maxlength='20' name='PropertyName' value='$PropertyName' readonly /><br>"; echo "<label for='PostCode'>Post Code*:</label><br>"; echo "<input id='PostCode' type='text' maxlength='20' name='PostCode' value='$PostCode' readonly /><br>"; echo "<label for='Date'>Date*:</label><br>"; echo "<input id='Date' type='date' maxlength='10' name='Date' value='Enter a Date' required /><br>"; echo "<label for='Time'>Time*:</label><br>"; echo "<input id='Time' type='time' maxlength='6' name='PostCode' value='Enter a Time' required /><br>"; echo "<br>"; echo "<input id='addcompletedviewing' type='submit' name='addcompletedviewing' value='Store Viewing' /><br>"; echo "</form>"; } }
  8. The code now looks like this $CustomerID = $rowcustomer['CustomerID']; $FirstName = $rowcustomer['FirstName']; $SecondName = $rowcustomer['SecondName']; $PhoneNumber = $rowcustomer['PhoneNumber']; $EmployeeID = $rowemployee['EmployeeID']; $EmpFirstName = $rowemployee['FirstName']; $EmpSecondName =$rowemployee['SecondName']; $ProductID = $rowproperty['ProductID']; $PropertyName = $rowproperty['PropertyName']; $PostCode = $rowproperty['PostCode']; But the form values are still empty.
  9. The strange lines are nothing I've deleted them. Just little bits left over from messing around with a few things. Ok its this bit that is giving me the problem. if (isset($_POST['addcustomertoviewing'])) { $CustomerID = $_GET['CustomerID']; $FirstName = $_GET['FirstName']; $SecondName = $_GET['SecondName']; $PhoneNumber = $_GET['PhoneNumber']; $EmployeeID = $_GET['EmployeeID']; $EmpFirstName = $_GET['FirstName']; $EmpSecondName = $_GET['SecondName']; $ProductID = $_GET['ProductID']; $PostCode = $_GET['PostCode']; $PropertyName = $_GET['PropertyName']; { echo "Please add a date and time for the viewing.<br>"; echo "<br>"; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "<label for='CustomerID'>Customer ID*:</label><br>"; echo "<input id='CustomerID' type='text' maxlength='20' name='CustomerID' value='$CustomerID' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$FirstName' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$SecondName' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='PhoneNumber'>Phone Number*:</label><br>"; echo "<input id='PhoneNumber' type='tel' maxlength='11' name='PhoneNumber' value='$PhoneNumber' pattern='^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$' required readonly/><br>"; echo "<label for='EmployeeID'>Employee ID*:</label><br>"; echo "<input id='EmployeeID' type='text' maxlength='20' name='ProductID' value='$EmployeeID' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$EmpFirstName' readonly /><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$EmpSecondName' readonly /><br>"; echo "<label for='ProductID'>Property ID*:</label><br>"; echo "<input id='ProductID' type='text' maxlength='20' name='ProductID' value='$ProductID' readonly /><br>"; echo "<label for='PropertyName'>Property Name*:</label><br>"; echo "<input id='PropertyName' type='text' maxlength='20' name='PropertyName' value='$PropertyName' readonly /><br>"; echo "<label for='PostCode'>Post Code*:</label><br>"; echo "<input id='PostCode' type='text' maxlength='20' name='PostCode' value='$PostCode' readonly /><br>"; echo "<label for='Date'>Date*:</label><br>"; echo "<input id='Date' type='date' maxlength='10' name='Date' value='Enter a Date' required /><br>"; echo "<label for='Time'>Time*:</label><br>"; echo "<input id='Time' type='time' maxlength='6' name='PostCode' value='Enter a Time' required /><br>"; echo "<br>"; echo "<input id='addcompletedviewing' type='submit' name='addcompletedviewing' value='Store Viewing' /><br>"; echo "</form>"; } } The variables aren't being echoed in the form despite them being set like this. $CustomerID = '$rowcustomer[CustomerID]'; $FirstName = '$rowcustomer[FirstName]'; $SecondName = '$rowcustomer[SecondName]'; $PhoneNumber = '$rowcustomer[PhoneNumber]'; $EmployeeID = '$rowemployee[EmployeeID]'; $EmpFirstName = '$rowemployee[FirstName]'; $EmpSecondName ='$rowemployee[SecondName]'; $ProductID ='$rowproperty[ProductID]' ; $PropertyName = '$rowproperty[PropertyName]'; $PostCode = '$rowproperty[PostCode]';
  10. I'm trying to reuse a variable. For example a query will echo out a row from the database. This is then echoed into a form. The values from the form are then stored into variables. When I echo out the variables in the same if statement as they are stored in, everything is fine. But when I try to use them outside of the if statement they are blank. Any ideas? Here is the code. <?php $newrecord = "Your viewing was added."; if (isset($_POST['submitpostcode'])) { $SearchPostCode = $_POST['SearchPostCode']; $error; $checkpostcode = "SELECT * from PropertyTable WHERE PostCode = '$SearchPostCode'"; $resultpostcode = mysql_query($checkpostcode); $count = mysql_num_rows($resultpostcode); if ($count == 0) { $_POST["SearchPostCode"] = $SearchPostCode; echo 'Sorry no properties were found with this Post Code. Please check it is entered correctly, then try again.'; } else { //show options $selectproperty ="SELECT * from PropertyTable WHERE PostCode = '$SearchPostCode'"; $propertyresults = mysql_query($selectproperty); echo"<div class='page-restrict-output'>"; echo "<form method='post' action='add-viewing'>"; echo "<input id='selectpropertybtn' type='Submit' name='selectpropertybtn' value='Select Property' /><br><br /></td></tr>"; echo "Here are the results, Select only ONE property or the operation will FAIL. <br>"; echo "<br>"; echo"<table id='selectviewingtable' border='1'>"; echo "<tr><th>Property Name</th><th>Post Code</th><th>Property ID</th><th>Add Viewing</th></tr>"; while($row = mysql_fetch_array($propertyresults)) { echo "<tr><td>"; echo $row['PropertyName']; echo "</td><td>"; echo $row['PostCode']; echo "</td><td>"; echo $row['ProductID']; echo "</td><td>"; echo $row['SelectViewing']; echo "<input id='selectviewingbutton' type='checkbox' name='selectedProductIDS[]' value='$row[ProductID]' /></td></tr>"; echo" </form>"; mysql_real_escape_string($PostCode); mysql_real_escape_string($newrecord); } } } if (isset($_POST['selectpropertybtn'])) { $_POST['selectedProductIDS']; { echo "<form action='add-viewing' autocomplete='on' method='post'>"; foreach($_POST['selectedProductIDS'] as $PropertyIDforviewing){ echo "<br>"; echo "You have Selected the following<br>"; echo "<br>"; $getpropertydetails = "SELECT * FROM PropertyTable Where ProductID = '$PropertyIDforviewing'"; $resultgetpropertydetails = mysql_query($getpropertydetails); $rowproperty = mysql_fetch_assoc($resultgetpropertydetails); $count = mysql_num_rows($resultgetpropertydetails); $ProductID = $_GET['ProductID']; $PostCode = $_GET['PostCode']; $PropertyName = $_GET['PropertyName']; } echo "<label for='ProductID'>Property ID*:</label><br>"; echo "<input id='ProductID' type='text' maxlength='20' name='ProductID' value='$rowproperty[ProductID]' readonly /><br>"; echo "<label for='PropertyName'>Property Name*:</label><br>"; echo "<input id='PropertyName' type='text' maxlength='20' name='PropertyName' value='$rowproperty[PropertyName]' readonly /><br>"; echo "<label for='PostCode'>Post Code*:</label><br>"; echo "<input id='PostCode' type='text' maxlength='20' name='PostCode' value='$rowproperty[PostCode]' readonly /><br>"; echo "<br>"; echo "Please Enter Your Employee ID Number."; echo "<br>"; echo "<br>"; echo "<label for='addEmployeeID'>Employee ID*:</label><br>"; echo "<input id='addEmployeeID' type='number' name='addEmployeeID' required /><br>"; echo "<br>"; echo "<input id='addemployeebtn' type='submit' name='addemployeebtn' value='Add Employee' /><br>"; echo "</form>"; $ProductID ='$rowproperty[ProductID]' ; $PropertyName = '$rowproperty[PropertyName]'; $PostCode = '$rowproperty[PostCode]'; } } if (isset($_POST['addemployeebtn'])) { $addEmployeeID = $_POST['addEmployeeID']; { echo "<form action='add-viewing' autocomplete='on' method='post'>"; echo "You have Selected Employee Number $addEmployeeID<br>"; $selectemployee = "SELECT * from EmployeeTable WHERE EmployeeID = '$addEmployeeID'"; $resultselectemployee = mysql_query($selectemployee); $rowemployee = mysql_fetch_assoc($resultselectemployee); $count = mysql_num_rows($resultselectemployee); echo "</form>"; if ($count == 0) { $_POST["addEmployeeID"] = $addEmployeeID; echo 'Sorry no employees were found with this ID Number. Please check it is entered correctly, then try again.'; } else { $EmployeeID = $_GET['EmployeeID']; $EmpFirstName = $_GET['FirstName']; $EmpSecondName = $_GET['SecondName']; { echo "<label for='EmployeeID'>Employee ID*:</label><br>"; echo "<input id='EmployeeID' type='text' maxlength='20' name='ProductID' value='$rowemployee[EmployeeID]' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$rowemployee[FirstName]' readonly /><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$rowemployee[SecondName]' readonly /><br>"; echo "<br>"; echo "<form action='add-viewing' autocomplete='on' method='post'>"; echo "<br>"; echo "Please enter a Customers First Name and Second Name to search for them, alternatively press the Show All Customers button to view the whole customer base across the system. <br>"; echo "<br>"; echo "<label for='SearchFirstName'>First Name*:</label><br>"; echo "<input id='SearchFirstName' type='text' maxlength='20' name='SearchFirstName' /><br>"; echo "<br>"; echo "<label for='SearchSecondName'>Second Name*:</label><br>"; echo "<input id='SearchSecondName' type='text' maxlength='20' name='SearchSecondName'/><br>"; echo "<br>"; echo "<input id='Submit' type='submit' name='searchcustomerbtn' value='Search' /><br>"; echo "<br>"; echo "<input id='Submit' type='submit' name='showcataloguecustomers' value='Show All Customers' /><br>"; $EmployeeID = '$rowemployee[EmployeeID]'; $EmpFirstName = '$rowemployee[FirstName]'; $EmpSecondName ='$rowemployee[SecondName]'; } } } } if (isset($_POST['searchcustomerbtn'])) { $SearchFirstName = $_POST['SearchFirstName']; $SearchSecondName = $_POST['SearchSecondName']; $error; $checkcustomer = "SELECT * from CustomerTable WHERE FirstName = '$SearchFirstName' AND SecondName = '$SearchSecondName'"; $resultcustomer = mysql_query($checkcustomer); $count = mysql_num_rows($resultcustomer); if ($count == 0) { $_POST["SearchFirstName"] = $SearchFirstName; $_POST["SearchSecondName"] = $SearchSecondName; echo 'Sorry no customers were found with these combinations of names. Please check they are entered correctly, then try again.'; } else { //show options $selectcustomer = "SELECT * from CustomerTable WHERE FirstName = '$SearchFirstName' AND SecondName = '$SearchSecondName'"; $customerresults = mysql_query($selectcustomer); echo"<div class='page-restrict-output'>"; echo "<form method='post' action='add-viewing'>"; echo "<input id='editcustomerbutton' type='Submit' name='editcustomerbtn' value='Select Customer' /><br><br /></td></tr>"; echo "Here are the results, Select only ONE Customer or the operation will FAIL. <br>"; echo "<br>"; echo"<table id='selectcustomertable' border='1'>"; echo "<tr><th>FirstName</th><th>SecondName</th><th>Address Line 1</th><th>Customer ID</th><th>Phone Number</th><th>E-Mail</th><th>Edit Customer</th></tr>"; while($rowcustomer = mysql_fetch_array($customerresults)) { echo "<tr><td>"; echo $rowcustomer['FirstName']; echo "</td><td>"; echo $rowcustomer['SecondName']; echo "</td><td>"; echo $rowcustomer['AddressLine1']; echo "</td><td>"; echo $rowcustomer['CustomerID']; echo "</td><td>"; echo $rowcustomer['PhoneNumber']; echo "</td><td>"; echo $rowcustomer['EMail']; echo "</td><td>"; echo $rowcustomer['EditCustomer']; echo "<input id='selectcustomerbutton' type='checkbox' name='selectedCustomerIDS[]' value='$rowcustomer[CustomerID]' /></td></tr>"; echo "</form>"; echo "</div>"; } } } if (isset($_POST['showcataloguecustomers'])) { $showallcustomers = "SELECT * from CustomerTable"; $allcustomerresults = mysql_query($showallcustomers); echo"<div class='page-restrict-output'>"; echo "<form method='post' action='add-viewing'>"; echo "<input id='editcustomerbutton' type='Submit' name='editcustomerbtn' value='Select Customer' /><br><br /></td></tr>"; echo "Here are the results, Select only ONE Customer to edit or the operation will FAIL. <br>"; echo "<br>"; echo"<table id='selectcustomertable' border='1'>"; echo "<tr><th>FirstName</th><th>SecondName</th><th>Address Line 1</th><th>Address Line 2</th><th>Address Line 3</th><th>Post Code</th><th>Customer ID</th><th>Phone Number</th><th>E-Mail</th><th>Edit Customer</th></tr>"; while($rowcustomer = mysql_fetch_array($allcustomerresults)) { echo "<tr><td>"; echo $rowcustomer['FirstName']; echo "</td><td>"; echo $rowcustomer['SecondName']; echo "</td><td>"; echo $rowcustomer['AddressLine1']; echo "</td><td>"; echo $rowcustomer['AddressLine2']; echo "</td><td>"; echo $rowcustomer['AddressLine3']; echo "</td><td>"; echo $rowcustomer['PostCode']; echo "</td><td>"; echo $rowcustomer['CustomerID']; echo "</td><td>"; echo $rowcustomer['PhoneNumber']; echo "</td><td>"; echo $rowcustomer['EMail']; echo "</td><td>"; echo $rowcustomer['EditCustomer']; echo "<input id='selectcustomerbutton' type='checkbox' name='selectedCustomerIDS[]' value='$rowcustomer[CustomerID]' /></td></tr>"; echo "</form>"; echo "</div>"; } } if (isset($_POST['editcustomerbtn'])) { $_POST['selectedCustomerIDS']; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "<br>"; foreach($_POST['selectedCustomerIDS'] as $CustomerIDforedit){ $theselectedrowcustomer = "SELECT * from CustomerTable WHERE CustomerID = '$CustomerIDforedit'"; $theselectedrowcustomerresults = mysql_query($theselectedrowcustomer); $rowcustomer = mysql_fetch_assoc($theselectedrowcustomerresults); $count = mysql_num_rows($theselectedrowcustomerresults); } if ($count == 1) { $CustomerID = $_GET['CustomerID']; $FirstName = $_GET['FirstName']; $SecondName = $_GET['SecondName']; $PhoneNumber = $_GET['PhoneNumber']; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "You have selected the following details.<br>"; echo "<br>"; echo "<label for='CustomerID'>Customer ID*:</label><br>"; echo "<input id='CustomerID' type='text' maxlength='20' name='CustomerID' value='$rowcustomer[CustomerID]' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$rowcustomer[FirstName]' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$rowcustomer[SecondName]' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='PhoneNumber'>Phone Number*:</label><br>"; echo "<input id='PhoneNumber' type='tel' maxlength='11' name='PhoneNumber' value='$rowcustomer[PhoneNumber]' pattern='^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$' required readonly/><br>"; echo "<br>"; echo "<input id='addcustomertoviewing' type='submit' name='addcustomertoviewing' value='Add Customer' /><br>"; $CustomerID = '$rowcustomer[CustomerID]'; $FirstName = '$rowcustomer[FirstName]'; $SecondName = '$rowcustomer[SecondName]'; $PhoneNumber = '$rowcustomer[PhoneNumber]'; echo "</form>"; } } if (isset($_POST['addcustomertoviewing'])) { $CustomerID = $_GET['CustomerID']; $FirstName = $_GET['FirstName']; $SecondName = $_GET['SecondName']; $PhoneNumber = $_GET['PhoneNumber']; $EmployeeID = $_GET['EmployeeID']; $EmpFirstName = $_GET['FirstName']; $EmpSecondName = $_GET['SecondName']; $ProductID = $_GET['ProductID']; $PostCode = $_GET['PostCode']; $PropertyName = $_GET['PropertyName']; { echo "Please add a date and time for the viewing.<br>"; echo "<form id=alleditcustomerform action='add-viewing' autocomplete='on' method='post' >"; echo "<label for='CustomerID'>Customer ID*:</label><br>"; echo "<input id='CustomerID' type='text' maxlength='20' name='CustomerID' value='$CustomerID' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$FirstName' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$SecondName' pattern='^[a-zA-Z]{2,20}$' required readonly/><br>"; echo "<label for='PhoneNumber'>Phone Number*:</label><br>"; echo "<input id='PhoneNumber' type='tel' maxlength='11' name='PhoneNumber' value='$PhoneNumber' pattern='^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$' required readonly/><br>"; echo "<label for='EmployeeID'>Employee ID*:</label><br>"; echo "<input id='EmployeeID' type='text' maxlength='20' name='ProductID' value='$EmployeeID' readonly /><br>"; echo "<label for='FirstName'>First Name*:</label><br>"; echo "<input id='FirstName' type='text' maxlength='20' name='FirstName' value='$EmpFirstName' readonly /><br>"; echo "<label for='SecondName'>Second Name*:</label><br>"; echo "<input id='SecondName' type='text' maxlength='20' name='SecondName' value='$EmpSecondName' readonly /><br>"; echo "<label for='ProductID'>Property ID*:</label><br>"; echo "<input id='ProductID' type='text' maxlength='20' name='ProductID' value='$ProductID' readonly /><br>"; echo "<label for='PropertyName'>Property Name*:</label><br>"; echo "<input id='PropertyName' type='text' maxlength='20' name='PropertyName' value='$PropertyName' readonly /><br>"; echo "<label for='PostCode'>Post Code*:</label><br>"; echo "<input id='PostCode' type='text' maxlength='20' name='PostCode' value='$PostCode' readonly /><br>"; echo "<label for='Date'>Date*:</label><br>"; echo "<input id='Date' type='date' maxlength='10' name='Date' value='Enter a Date' required /><br>"; echo "<label for='Time'>Time*:</label><br>"; echo "<input id='Time' type='time' maxlength='6' name='PostCode' value='Enter a Time' required /><br>"; echo "<br>"; echo "<input id='addcompletedviewing' type='submit' name='addcompletedviewing' value='Store Viewing' /><br>"; echo "</form>"; } } ?>
  11. Thanks that solved the issue. As for $_POST['selectedProductIDS'] it was incomplete it now reads foreach($_POST['selectedProductIDS'] as $PropertyIDforviewing){
  12. Ok I'm having trouble with the next stage. It's probably something stupid but I can't seem to figure out why. After the user selects a property, the property variable is stored for use later. This works. PHP then echoes out another form when the Select Property button is pressed. The form that is echoed out allows a user to enter an Employee ID (to assign an employee to the viewing). This form is echoed out and it has a button called Add Employee. Once this button is pressed the Employee ID the user has entered is checked against the database to ensure its a legitimate entry and if it is the Employee ID is stored in a variable for use later. The system then echoes out saying you have selected employee number [variable that has been stored]. The problem is here. Instead of doing any of this the form just redirects to the start once the add employee button is pressed. No error messages. No success messages. It's probably something small and stupid but I can't seem to find it looking at each line individually. Here is the code. $newrecord = "Your viewing was added."; if (isset($_POST['submitpostcode'])) { $SearchPostCode = $_POST['SearchPostCode']; $error; $checkpostcode = "SELECT * from PropertyTable WHERE PostCode = '$SearchPostCode'"; $resultpostcode = mysql_query($checkpostcode); $count = mysql_num_rows($resultpostcode); if ($count == 0) { $_POST["SearchPostCode"] = $SearchPostCode; echo 'Sorry no properties were found with this Post Code. Please check it is entered correctly, then try again.'; } else { //show options $selectproperty ="SELECT * from PropertyTable WHERE PostCode = '$SearchPostCode'"; $propertyresults = mysql_query($selectproperty); echo"<div class='page-restrict-output'>"; echo "<form method='post' action='add-viewing'>"; echo "<input id='selectpropertybtn' type='Submit' name='selectpropertybtn' value='Select Property' /><br><br /></td></tr>"; echo "Here are the results, Select only ONE property or the operation will FAIL. <br>"; echo "<br>"; echo"<table id='selectviewingtable' border='1'>"; echo "<tr><th>Property Name</th><th>Post Code</th><th>Property ID</th><th>Add Viewing</th></tr>"; while($row = mysql_fetch_array($propertyresults)) { echo "<tr><td>"; echo $row['PropertyName']; echo "</td><td>"; echo $row['PostCode']; echo "</td><td>"; echo $row['ProductID']; echo "</td><td>"; echo $row['SelectViewing']; echo "<input id='selectviewingbutton' type='checkbox' name='selectedProductIDS[]' value='$row[ProductID]' /></td></tr>"; echo" </form>"; mysql_real_escape_string($PostCode); mysql_real_escape_string($newrecord); } } } if (isset($_POST['selectpropertybtn'])) { $_POST['selectedProductIDS']; { echo "<form action='add-viewing' autocomplete='on' method='post'>"; foreach($_POST['selectedProductIDS'] as $PropertyIDforviewing){ echo "<br>"; echo "You have Selected Property Number $PropertyIDforviewing.<br>"; echo "<br>"; } echo "Please Enter Your Employee ID Number."; echo "<br>"; echo "<br>"; echo "<label for='addEmployeeID'>Employee ID*:</label><br>"; echo "<input id='addEmployeeID' type='number' name='$addEmployeeID' required /><br>"; echo "<br>"; echo "<input id='addemployeebtn' type='submit' name='addemployeebtn' value='Add Employee' /><br>"; echo "</form>"; } if (isset($_POST['addemployeebtn'])) { $addEmployeeID = $_POST['addEmployeeID']; { echo "You have Selected Employee Number $addEmployeeID.<br>"; $selectemployee = "SELECT * from EmployeeTable WHERE EmployeeID = '$addEmployeeID'"; $resultselectemployee = mysql_query($selectemployeee); $count = mysql_num_rows($resultselectemployee); } if ($count == 0) { $_POST["addEmployeeID"] = $addEmployeeID; echo 'Sorry no employees were found with this ID Number. Please check it is entered correctly, then try again.'; } else { $selectemployee = "SELECT * from EmployeeTable WHERE EmployeeID = '$addEmployeeID'"; $resultselectemployee = mysql_query($selectemployeee); $count = mysql_num_rows($resultselectemployee); $row = mysql_fetch_assoc($resultselectemployee); } } }
  13. Perfect that is all it is. It's now fully working with all the results echoing into the fields. Thanks you so much
  14. The code looks like this $theselectedrow = "SELECT * from CustomerTable WHERE 'CustomerID' = '13'"; $theselectedrowresults = mysql_query($theselectedrow); $row = mysql_fetch_assoc($theselectedrowresults);
×
×
  • 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.