Jump to content

Parkie02

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by Parkie02

  1. Can somebody maybe help me to display 10 records and then there must be like a button or so that shows next or like 2,3,4 Here is my code. I tried to use the webpages explaining it but struggled <!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> <title>Search</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">All Companies:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Company Name</th> <th>Email</th> <th>Companies not Paid</th> <th>Amount not Paid</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "mj2015") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $sql="SELECT d_name,email,companies_not_paid,amount_not_paid FROM debtor ORDER BY d_name"; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$debtor['d_name']."</td>"; echo "<td>".$debtor['email']."</td>"; echo "<td>".$debtor['companies_not_paid']."</td>"; echo "<td>".$debtor['amount_not_paid']."</td>"; } mysql_close($db); ?> Thank you
  2. Can someone maybe help me. If I click on a record for instance d_name I want to show another another page that will contain the details of that record, the details is stored in a database table. What I want to do is if I click of the name of the company (d_name) then a new page must open which shows the information about that company that I will create. Here is my code: <!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> <title>Search</title> <meta name="description" content=""> <meta name="keywords" content=""> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="main"> <div class="page"> <div class="header"> <div class="header-img"> <h1>Who Didn't Pay</h1> <p> </p> </div> <div class="menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="registration.php">Register</a></li> <li><a href="complaint.php">Complaint</a></li> <li><a href="search.php">Search</a></li> <li><a href="#">Contact Us</a></li> <li><a href="login.php">Login</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <div class="content"> <div class="left-panel"> <div class="left-panel-in"> <h2 class="title">All Companies:</h2> <p> </p> <p> </p> <p> <form method="post" action="allcompanies.php?go" id="showallform"> <p> </p> <p> </p> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Company Name</th> <th>Email</th> <th>Companies not Paid</th> <th>Amount not Paid</th> <tr> </form> </p> </body></html> <?php //connect to the database $db=mysql_connect ("localhost", "root", "mj2015") or die ('I cannot connect to the database because: ' . mysql_error()); //-select the database to use $mydb=mysql_select_db("whodidntpay"); //-query the database table $sql="SELECT d_name,email,companies_not_paid,amount_not_paid FROM debtor ORDER BY d_name"; //-run the query against the mysql query function $result=mysql_query($sql); //-count results $numrows=mysql_num_rows($result); echo "<p>" .$numrows . " results found "; while($debtor=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$debtor['d_name']."</td>"; echo "<td>".$debtor['email']."</td>"; echo "<td>".$debtor['companies_not_paid']."</td>"; echo "<td>".$debtor['amount_not_paid']."</td>"; } mysql_close($db); ?> I now want to click on a company name and then a page must be shown with the details of the company. Thank you
  3. Can someone maybe help me. I am new to php mysql and I am trying to create a search form where a user type in a name and the record of that name is displayed. Here is the error I get: Undefined variable: cname in C:\wamp\www\whodidntpay\search.php on line 32. Here is my code: <html> <head>Search</title> </head> <p> Company Name: <input type=text name=cname size=50 maxlength=50> <p> <input type=submit> <body> <table width="600" border="1" cellpadding="1" cellspacing="1"> <tr> <th>Company Name</th> <th>Reg</th> <th>Email</th> <th>Per</th> <th>Num</th> <th>NotPaid</th> <th>Amount</th> <tr> <?php mysql_connect('localhost', 'root', ''); mysql_select_db('whodidntpay'); // if ($cname == "") //{$cname = '%';} $sql="SELECT * FROM debtor WHERE cname LIKE '$cname%'"; $records=mysql_query($sql); ?> while ($debtor=mysql_fetch_assoc($records)) { echo "<tr>"; echo "<td>".$debtor['d_name']."</td>"; echo "<td>".$debtor['registration_nr']."</td>"; echo "<td>".$debtor['email']."</td>"; echo "<td>".$debtor['contact_person']."</td>"; echo "<td>".$debtor['contact_number']."</td>"; echo "<td>".$debtor['companies_not_paid']."</td>"; echo "<td>".$debtor['amount_not_paid']."</td>"; } </html> Thank you
  4. Can somebody maybe tell me is there an easier way to create the look of the website the html part. For example here is my code <html> <head> <title> Registration Form </title> </head> <body> <form method='post' action='registration.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Registration Form</h1></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' /></td> </tr> <tr> <td>Company Name:</td> <td><input type='text' name='company' /></td> </tr> <tr> <td>Registration Number:</td> <td><input type='text' name='reg_nr' /></td> </tr> <tr> <td>Telephone Number:</td> <td><input type='text' name='telephone' /></td> </tr> <tr> <td>Address:</td> </tr> <tr> <td>Street:</td> <td><input type='text' name='street' /></td> </tr> <tr> <td>Suburb:</td> <td><input type='text' name='suburb' /></td> </tr> <tr> <td>City:</td> <td><input type='text' name='city' /></td> </tr> <tr> <td>Province:</td> <td><input type='text' name='province' /></td> </tr> <tr> <td>Postal Code:</td> <td><input type='text' name='postalcode' /></td> </tr> <tr> <td>Contact Person:</td> <td><input type='text' name='contact_person' /></td> </tr> <tr> <td>Contact Person Telephone Number:</td> <td><input type='text' name='contact_person_tel' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='submit' value='Sign Up' /></td> </tr> </table> </form> <center><b>Already Registered</b><br><a href= 'login.php'>Login Here</a></center> </body> </html> <?php mysql_connect("localhost","root",""); mysql_select_db("whodidntpay"); if(isset($_POST['submit'])) { $com_password = $_POST['password']; $com_email = $_POST['email']; $com_companyname = $_POST['company']; $com_registration = $_POST['reg_nr']; $com_telephone = $_POST['telephone']; $com_street = $_POST['street']; $com_suburb = $_POST['suburb']; $com_city = $_POST['city']; $com_province = $_POST['province']; $com_postalcode = $_POST['postalcode']; $com_contactperson = $_POST['contact_person']; $com_contactpersontel = $_POST['contact_person_tel']; if($com_email=='') { echo "<script>alert('Please Enter Email')</script>"; exit(); } if($com_password=='') { echo "<script>alert('Please Enter Password')</script>"; exit(); } if($com_companyname=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } if($com_registration=='') { echo "<script>alert('Please Enter Registration Number')</script>"; exit(); } if($com_telephone=='') { echo "<script>alert('Please Enter Telephone Number')</script>"; exit(); } if($com_street=='') { echo "<script>alert('Please Enter Street Name')</script>"; exit(); } if($com_suburb=='') { echo "<script>alert('Please Enter Suburb Name')</script>"; exit(); } if($com_city=='') { echo "<script>alert('Please Enter City')</script>"; exit(); } if($com_province=='') { echo "<script>alert('Please Enter Province')</script>"; exit(); } if($com_postalcode=='') { echo "<script>alert('Please Enter Postel Code')</script>"; exit(); } if($com_contactperson=='') { echo "<script>alert('Please Enter Contact Person Name')</script>"; exit(); } if($com_contactpersontel=='') { echo "<script>alert('Please Enter Contact Person Telphone Nr')</script>"; exit(); } $check_email = "select * from complainant where email='$com_email'"; $run = mysql_query($check_email); if(mysql_num_rows($run)>0) { echo"<script>alert('Email $com_email already exists, please use another email')</script>"; exit(); } $query = "insert into complainant(email,password,company_name,registration_nr,telephone_nr,street,suburb,city,province,postal_code,contact_person,contact_person_tel) values ('$com_email','$com_password','$com_companyname','$com_registration','$com_telephone','$com_street','$com_suburb','$com_city','$com_province','$com_postalcode','$com_contactperson','$com_contactpersontel')"; if (mysql_query($query)) { echo "<script>alert('Registration Successful')</script>"; echo "<script>window.open('welcome.php','_self')</script>"; } } ?> Is there any way to create the html part with software and then just add the php part. Because doing it like this it is difficult for me to create a webpage that looks good.
  5. Can somebody tell me why there is two complaint records added to the complaint table when I am entering information of somebody and how I can fix it. Here is the new code <?php session_start(); if(!$_SESSION['email']) { header("location:login.php"); } ?> <html> <head> <title> Complaint </title> </head> <body> <form method='post' action='complaint.php'> <table width='800' border='10' align='left'> <tr> <td align='center' colspan='5'><h1>Complaint Form</h1></td> </tr> <tr> <td>Comany's Name:</td> <td><input type='text' name='comp_name' /></td> </tr> <tr> <td>Registration Number:</td> <td><input type='text' name='reg_nr' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='comp_email' /></td> </tr> <tr> <td>Contact Person:</td> <td><input type='text' name='comp_contact_person' /></td> </tr> <tr> <td>Contact Number:</td> <td><input type='text' name='comp_contactnr' /></td> </tr> <tr> <td>Details of complain:</td> <td><input type='text' name='complain_details' /></td> </tr> <tr> <td>Order Number:</td> <td><input type='text' name='order_nr' /></td> </tr> <tr> <td>Order Description:</td> <td><input type='text' name='order_desc' /></td> </tr> <tr> <td>Order Date:</td> <td><input type='date' name='order_date' /></td> </tr> <tr> <td>Delivery Date:</td> <td><input type='date' name='delivery_date' /></td> </tr> <tr> <td>Invoice Date:</td> <td><input type='date' name='invoice_date' /></td> </tr> <tr> <td>Delivery Number:</td> <td><input type='text' name='delivery_nr' /></td> </tr> <tr> <td>Order Amount:</td> <td><input type='number' step='0.01' name='order_amount' /></td> </tr> <tr> <td>Amount Already Paid:</td> <td><input type='number' step='0.01' name='amount_paid' /></td> </tr> <tr> <td>Amount Outstanding:</td> <td><input type='number' step='0.01' name='amount_outstanding' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='add_debtor' value='Submit' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root","mj2015"); mysql_select_db("whodidntpay"); $log = $_SESSION['email']; if(isset($_POST['add_debtor'])) { $comp_name = $_POST['comp_name']; $comp_regnr = $_POST['reg_nr']; $comp_email = $_POST['comp_email']; $comp_contact_person = $_POST['comp_contact_person']; $comp_contact_nr = $_POST['comp_contactnr']; $complain_det = $_POST['complain_details']; $ordernr = $_POST['order_nr']; $orderdesc = $_POST['order_desc']; $orderdate = $_POST['order_date']; $deliverydate = $_POST['delivery_date']; $invoicedate = $_POST['invoice_date']; $deliverynr = $_POST['delivery_nr']; $orderamount = $_POST['order_amount']; $paidamount = $_POST['amount_paid']; $outstandamount = $_POST['amount_outstanding']; if($comp_name=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } if($comp_regnr=='') { echo "<script>alert('Please Enter Company Registration Number')</script>"; exit(); } if($comp_email=='') { echo "<script>alert('Please Enter Company Email')</script>"; exit(); } if($comp_contact_person=='') { echo "<script>alert('Please Enter Contact Person')</script>"; exit(); } if($comp_contact_nr=='') { echo "<script>alert('Please Enter Contact Number')</script>"; exit(); } if($complain_det=='') { echo "<script>alert('Please Enter Complain Details')</script>"; exit(); } if($ordernr=='') { echo "<script>alert('Please Enter Order Number')</script>"; exit(); } if($orderdesc=='') { echo "<script>alert('Please Enter Order Description')</script>"; exit(); } if($orderdate=='') { echo "<script>alert('Please Enter Order Date')</script>"; exit(); } if($deliverydate=='') { echo "<script>alert('Please Enter Delivery Date')</script>"; exit(); } if($invoicedate=='') { echo "<script>alert('Please Enter Invoice Date')</script>"; exit(); } if($deliverynr=='') { echo "<script>alert('Please Enter Delivery Number')</script>"; exit(); } if($orderamount=='') { echo "<script>alert('Please Enter Order Amount')</script>"; exit(); } if($paidamount=='') { echo "<script>alert('Please Enter Amount Paid')</script>"; exit(); } if($outstandamount=='') { echo "<script>alert('Please Enter The Amount Outstanding')</script>"; exit(); } $num_debt = "select * from debtor where d_name= '$comp_name' AND registration_nr= '$comp_regnr'"; $run = mysql_query($num_debt); $num_comp = mysql_num_rows($run); if ($num_comp ==0) $query = "insert into debtor(d_name,registration_nr,email,contact_person,contact_number,companies_not_paid,amount_not_paid) values ('$comp_name','$comp_regnr','$comp_email','$comp_contact_person','$comp_contact_nr','1','$outstandamount')"; if ($num_comp ==1) $query = "update debtor set companies_not_paid = companies_not_paid + 1, amount_not_paid = amount_not_paid + '$outstandamount' where d_name='$comp_name'"; if (mysql_query($query)) { echo "<script>alert('Company Added Successful')</script>"; } $complain_id = "select complainant_id from complainant where email = '$log'"; $run2=mysql_query($complain_id); $row = mysql_fetch_assoc($run2); $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','{$row['complainant_id']}')"; mysql_query($query2); $the_auto_id_that_was_just_created = mysql_insert_id(); if (mysql_query($query2)) { echo "<script>alert('Complaint Added Successful')</script>"; } $query3 = "insert into complaint_details(order_nr,order_description,order_date,delivery_date,invoice_date,delivery_nr,complaint_nr,order_amount,amount_paid,amount_outstanding) values ('$ordernr','$orderdesc','$orderdate','$deliverydate','$invoicedate','$deliverynr','$the_auto_id_that_was_just_created','$orderamount','$paidamount','$outstandamount')"; if (mysql_query($query3)) { echo "<script>alert('Complaint Details Added Successful')</script>"; } } ?> The insert command of complaint is at query2 almost at the end of the code. Thank you
  6. Thank you. Can somebody tell me why there is now added two complaint records to the complaint table and how I can fix it. Here is the new code <?php session_start(); if(!$_SESSION['email']) { header("location:login.php"); } ?> <html> <head> <title> Complaint </title> </head> <body> <form method='post' action='complaint.php'> <table width='800' border='10' align='left'> <tr> <td align='center' colspan='5'><h1>Complaint Form</h1></td> </tr> <tr> <td>Comany's Name:</td> <td><input type='text' name='comp_name' /></td> </tr> <tr> <td>Registration Number:</td> <td><input type='text' name='reg_nr' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='comp_email' /></td> </tr> <tr> <td>Contact Person:</td> <td><input type='text' name='comp_contact_person' /></td> </tr> <tr> <td>Contact Number:</td> <td><input type='text' name='comp_contactnr' /></td> </tr> <tr> <td>Details of complain:</td> <td><input type='text' name='complain_details' /></td> </tr> <tr> <td>Order Number:</td> <td><input type='text' name='order_nr' /></td> </tr> <tr> <td>Order Description:</td> <td><input type='text' name='order_desc' /></td> </tr> <tr> <td>Order Date:</td> <td><input type='date' name='order_date' /></td> </tr> <tr> <td>Delivery Date:</td> <td><input type='date' name='delivery_date' /></td> </tr> <tr> <td>Invoice Date:</td> <td><input type='date' name='invoice_date' /></td> </tr> <tr> <td>Delivery Number:</td> <td><input type='text' name='delivery_nr' /></td> </tr> <tr> <td>Order Amount:</td> <td><input type='number' step='0.01' name='order_amount' /></td> </tr> <tr> <td>Amount Already Paid:</td> <td><input type='number' step='0.01' name='amount_paid' /></td> </tr> <tr> <td>Amount Outstanding:</td> <td><input type='number' step='0.01' name='amount_outstanding' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='add_debtor' value='Submit' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root","mj2015"); mysql_select_db("whodidntpay"); $log = $_SESSION['email']; if(isset($_POST['add_debtor'])) { $comp_name = $_POST['comp_name']; $comp_regnr = $_POST['reg_nr']; $comp_email = $_POST['comp_email']; $comp_contact_person = $_POST['comp_contact_person']; $comp_contact_nr = $_POST['comp_contactnr']; $complain_det = $_POST['complain_details']; $ordernr = $_POST['order_nr']; $orderdesc = $_POST['order_desc']; $orderdate = $_POST['order_date']; $deliverydate = $_POST['delivery_date']; $invoicedate = $_POST['invoice_date']; $deliverynr = $_POST['delivery_nr']; $orderamount = $_POST['order_amount']; $paidamount = $_POST['amount_paid']; $outstandamount = $_POST['amount_outstanding']; if($comp_name=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } if($comp_regnr=='') { echo "<script>alert('Please Enter Company Registration Number')</script>"; exit(); } if($comp_email=='') { echo "<script>alert('Please Enter Company Email')</script>"; exit(); } if($comp_contact_person=='') { echo "<script>alert('Please Enter Contact Person')</script>"; exit(); } if($comp_contact_nr=='') { echo "<script>alert('Please Enter Contact Number')</script>"; exit(); } if($complain_det=='') { echo "<script>alert('Please Enter Complain Details')</script>"; exit(); } if($ordernr=='') { echo "<script>alert('Please Enter Order Number')</script>"; exit(); } if($orderdesc=='') { echo "<script>alert('Please Enter Order Description')</script>"; exit(); } if($orderdate=='') { echo "<script>alert('Please Enter Order Date')</script>"; exit(); } if($deliverydate=='') { echo "<script>alert('Please Enter Delivery Date')</script>"; exit(); } if($invoicedate=='') { echo "<script>alert('Please Enter Invoice Date')</script>"; exit(); } if($deliverynr=='') { echo "<script>alert('Please Enter Delivery Number')</script>"; exit(); } if($orderamount=='') { echo "<script>alert('Please Enter Order Amount')</script>"; exit(); } if($paidamount=='') { echo "<script>alert('Please Enter Amount Paid')</script>"; exit(); } if($outstandamount=='') { echo "<script>alert('Please Enter The Amount Outstanding')</script>"; exit(); } $num_debt = "select * from debtor where d_name= '$comp_name' AND registration_nr= '$comp_regnr'"; $run = mysql_query($num_debt); $num_comp = mysql_num_rows($run); if ($num_comp ==0) $query = "insert into debtor(d_name,registration_nr,email,contact_person,contact_number,companies_not_paid,amount_not_paid) values ('$comp_name','$comp_regnr','$comp_email','$comp_contact_person','$comp_contact_nr','1','$outstandamount')"; if ($num_comp ==1) $query = "update debtor set companies_not_paid = companies_not_paid + 1, amount_not_paid = amount_not_paid + '$outstandamount' where d_name='$comp_name'"; if (mysql_query($query)) { echo "<script>alert('Company Added Successful')</script>"; } $complain_id = "select complainant_id from complainant where email = '$log'"; $run2=mysql_query($complain_id); $row = mysql_fetch_assoc($run2); $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','{$row['complainant_id']}')"; mysql_query($query2); $the_auto_id_that_was_just_created = mysql_insert_id(); if (mysql_query($query2)) { echo "<script>alert('Complaint Added Successful')</script>"; } $query3 = "insert into complaint_details(order_nr,order_description,order_date,delivery_date,invoice_date,delivery_nr,complaint_nr,order_amount,amount_paid,amount_outstanding) values ('$ordernr','$orderdesc','$orderdate','$deliverydate','$invoicedate','$deliverynr','$the_auto_id_that_was_just_created','$orderamount','$paidamount','$outstandamount')"; if (mysql_query($query3)) { echo "<script>alert('Complaint Details Added Successful')</script>"; } } ?>
  7. Can you maybe help me apply it directly on my problem. So with this query3 insert I want to insert all of the values below plus the details_id that is automatically added because of the auto increment and then also complaint_id that I want to add that is the foreign key for this table and primary key for the complaint table. $query3 = "insert into complaint_details(order_nr,order_description,order_date,delivery_date,invoice_date,delivery_nr,order_amount,amount_paid,amount_outstanding) values ('$ordernr','$orderdesc','$orderdate','$deliverydate','$invoicedate','$deliverynr','$orderamount','$paidamount','$outstandamount')";
  8. The table complaint_details consists of everything stated in query 3 and also details_id that is the primary key and also auto increment and then also complaint_nr that is the foreign key that I dont know how to add
  9. Can somebody maybe help me. I have got a complaint and complaint_details table. Complaint_nr is my primary key in complaint and foreign key in complaint_details. How can i show the complaint_nr in my complaint_details table. I have created the tables and in both there are a field for complaint_nr. It is an auto increment in complaint and also the primary key. And in complaint_details it is an int field and the foreign key. Here is my code. At $query3 I try to insert data into complaint_details. <?php session_start(); if(!$_SESSION['email']) { header("location:login.php"); } ?> <html> <head> <title> Complaint </title> </head> <body> <form method='post' action='complaint.php'> <table width='800' border='10' align='left'> <tr> <td align='center' colspan='5'><h1>Complaint Form</h1></td> </tr> <tr> <td>Comany's Name:</td> <td><input type='text' name='comp_name' /></td> </tr> <tr> <td>Registration Number:</td> <td><input type='text' name='reg_nr' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='comp_email' /></td> </tr> <tr> <td>Contact Person:</td> <td><input type='text' name='comp_contact_person' /></td> </tr> <tr> <td>Contact Number:</td> <td><input type='text' name='comp_contactnr' /></td> </tr> <tr> <td>Details of complain:</td> <td><input type='text' name='complain_details' /></td> </tr> <tr> <td>Order Number:</td> <td><input type='text' name='order_nr' /></td> </tr> <tr> <td>Order Description:</td> <td><input type='text' name='order_desc' /></td> </tr> <tr> <td>Order Date:</td> <td><input type='date' name='order_date' /></td> </tr> <tr> <td>Delivery Date:</td> <td><input type='date' name='delivery_date' /></td> </tr> <tr> <td>Invoice Date:</td> <td><input type='date' name='invoice_date' /></td> </tr> <tr> <td>Delivery Number:</td> <td><input type='text' name='delivery_nr' /></td> </tr> <tr> <td>Order Amount:</td> <td><input type='number' step='0.01' name='order_amount' /></td> </tr> <tr> <td>Amount Already Paid:</td> <td><input type='number' step='0.01' name='amount_paid' /></td> </tr> <tr> <td>Amount Outstanding:</td> <td><input type='number' step='0.01' name='amount_outstanding' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='add_debtor' value='Submit' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root","mj2015"); mysql_select_db("whodidntpay"); $log = $_SESSION['email']; if(isset($_POST['add_debtor'])) { $comp_name = $_POST['comp_name']; $comp_regnr = $_POST['reg_nr']; $comp_email = $_POST['comp_email']; $comp_contact_person = $_POST['comp_contact_person']; $comp_contact_nr = $_POST['comp_contactnr']; $complain_det = $_POST['complain_details']; $ordernr = $_POST['order_nr']; $orderdesc = $_POST['order_desc']; $orderdate = $_POST['order_date']; $deliverydate = $_POST['delivery_date']; $invoicedate = $_POST['invoice_date']; $deliverynr = $_POST['delivery_nr']; $orderamount = $_POST['order_amount']; $paidamount = $_POST['amount_paid']; $outstandamount = $_POST['amount_outstanding']; if($comp_name=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } if($comp_regnr=='') { echo "<script>alert('Please Enter Company Registration Number')</script>"; exit(); } if($comp_email=='') { echo "<script>alert('Please Enter Company Email')</script>"; exit(); } if($comp_contact_person=='') { echo "<script>alert('Please Enter Contact Person')</script>"; exit(); } if($comp_contact_nr=='') { echo "<script>alert('Please Enter Contact Number')</script>"; exit(); } if($complain_det=='') { echo "<script>alert('Please Enter Complain Details')</script>"; exit(); } if($ordernr=='') { echo "<script>alert('Please Enter Order Number')</script>"; exit(); } if($orderdesc=='') { echo "<script>alert('Please Enter Order Description')</script>"; exit(); } if($orderdate=='') { echo "<script>alert('Please Enter Order Date')</script>"; exit(); } if($deliverydate=='') { echo "<script>alert('Please Enter Delivery Date')</script>"; exit(); } if($invoicedate=='') { echo "<script>alert('Please Enter Invoice Date')</script>"; exit(); } if($deliverynr=='') { echo "<script>alert('Please Enter Delivery Number')</script>"; exit(); } if($orderamount=='') { echo "<script>alert('Please Enter Order Amount')</script>"; exit(); } if($paidamount=='') { echo "<script>alert('Please Enter Amount Paid')</script>"; exit(); } if($outstandamount=='') { echo "<script>alert('Please Enter The Amount Outstanding')</script>"; exit(); } $num_debt = "select * from debtor where d_name= '$comp_name' AND registration_nr= '$comp_regnr'"; $run = mysql_query($num_debt); $num_comp = mysql_num_rows($run); if ($num_comp ==0) $query = "insert into debtor(d_name,registration_nr,email,contact_person,contact_number,companies_not_paid,amount_not_paid) values ('$comp_name','$comp_regnr','$comp_email','$comp_contact_person','$comp_contact_nr','1','$outstandamount')"; if ($num_comp ==1) $query = "update debtor set companies_not_paid = companies_not_paid + 1, amount_not_paid = amount_not_paid + '$outstandamount' where d_name='$comp_name'"; if (mysql_query($query)) { echo "<script>alert('Company Added Successful')</script>"; } $complain_id = "select complainant_id from complainant where email = '$log'"; $run2=mysql_query($complain_id); $row = mysql_fetch_assoc($run2); $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','{$row['complainant_id']}')"; if (mysql_query($query2)) { echo "<script>alert('Complaint Added Successful')</script>"; } $query3 = "insert into complaint_details(order_nr,order_description,order_date,delivery_date,invoice_date,delivery_nr,order_amount,amount_paid,amount_outstanding) values ('$ordernr','$orderdesc','$orderdate','$deliverydate','$invoicedate','$deliverynr','$orderamount','$paidamount','$outstandamount')"; } ?> Any help will be appreciated
  10. The email for the SESSION command is the email from the complainant table
  11. Can somebody maybe tell me why my insert command does not work correct. An user register and log in. Then the user can send a complaint. In my one table I want to show which user send the complaint via the complainant id. Here is the part of code not working: $log = $_SESSION['email']; $complain_id = "select complainant_id from complainant where email = '$log'"; $run2=mysql_query($complain_id); echo $run2; $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','$run2')"; if (mysql_query($query2)) { echo "<script>alert('Complaint Added Successful')</script>"; } Here is the whole complaint.php part: <?php session_start(); if(!$_SESSION['email']) { header("location:login.php"); } ?> <html> <head> <title> Complaint </title> </head> <body> <form method='post' action='complaint.php'> <table width='800' border='10' align='left'> <tr> <td align='center' colspan='5'><h1>Complaint Form</h1></td> </tr> <tr> <td>Comany's Name:</td> <td><input type='text' name='comp_name' /></td> </tr> <tr> <td>Registration Number:</td> <td><input type='text' name='reg_nr' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='comp_email' /></td> </tr> <tr> <td>Contact Person:</td> <td><input type='text' name='comp_contact_person' /></td> </tr> <tr> <td>Contact Number:</td> <td><input type='text' name='comp_contactnr' /></td> </tr> <tr> <td>Details of complain:</td> <td><input type='text' name='complain_details' /></td> </tr> <tr> <td>Order Number:</td> <td><input type='text' name='order_nr' /></td> </tr> <tr> <td>Order Description:</td> <td><input type='text' name='order_desc' /></td> </tr> <tr> <td>Order Date:</td> <td><input type='date' name='order_date' /></td> </tr> <tr> <td>Delivery Date:</td> <td><input type='date' name='delivery_date' /></td> </tr> <tr> <td>Invoice Date:</td> <td><input type='date' name='invoice_date' /></td> </tr> <tr> <td>Delivery Number:</td> <td><input type='text' name='delivery_nr' /></td> </tr> <tr> <td>Order Amount:</td> <td><input type='number' step='0.01' name='order_amount' /></td> </tr> <tr> <td>Amount Already Paid:</td> <td><input type='number' step='0.01' name='amount_paid' /></td> </tr> <tr> <td>Amount Outstanding:</td> <td><input type='number' step='0.01' name='amount_outstanding' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='add_debtor' value='Submit' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root","mj2015"); mysql_select_db("whodidntpay"); $log = $_SESSION['email']; if(isset($_POST['add_debtor'])) { $comp_name = $_POST['comp_name']; $comp_regnr = $_POST['reg_nr']; $comp_email = $_POST['comp_email']; $comp_contact_person = $_POST['comp_contact_person']; $comp_contact_nr = $_POST['comp_contactnr']; $complain_det = $_POST['complain_details']; $ordernr = $_POST['order_nr']; $orderdesc = $_POST['order_desc']; $orderdate = $_POST['order_date']; $deliverydate = $_POST['delivery_date']; $invoicedate = $_POST['invoice_date']; $deliverynr = $_POST['delivery_nr']; $orderamount = $_POST['order_amount']; $paidamount = $_POST['amount_paid']; $outstandamount = $_POST['amount_outstanding']; if($comp_name=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } if($comp_regnr=='') { echo "<script>alert('Please Enter Company Registration Number')</script>"; exit(); } if($comp_email=='') { echo "<script>alert('Please Enter Company Email')</script>"; exit(); } if($comp_contact_person=='') { echo "<script>alert('Please Enter Contact Person')</script>"; exit(); } if($comp_contact_nr=='') { echo "<script>alert('Please Enter Contact Number')</script>"; exit(); } if($complain_det=='') { echo "<script>alert('Please Enter Complain Details')</script>"; exit(); } if($orderdesc=='') { echo "<script>alert('Please Enter Order Description')</script>"; exit(); } if($orderdate=='') { echo "<script>alert('Please Enter Order Date')</script>"; exit(); } if($deliverydate=='') { echo "<script>alert('Please Enter Delivery Date')</script>"; exit(); } if($invoicedate=='') { echo "<script>alert('Please Enter Invoice Date')</script>"; exit(); } if($deliverynr=='') { echo "<script>alert('Please Enter Delivery Number')</script>"; exit(); } if($orderamount=='') { echo "<script>alert('Please Enter Order Amount')</script>"; exit(); } if($paidamount=='') { echo "<script>alert('Please Enter Amount Paid')</script>"; exit(); } if($outstandamount=='') { echo "<script>alert('Please Enter The Amount Outstanding')</script>"; exit(); } $num_debt = "select * from debtor where d_name= '$comp_name' AND registration_nr= '$comp_regnr'"; $run = mysql_query($num_debt); $num_comp = mysql_num_rows($run); if ($num_comp ==0) $query = "insert into debtor(d_name,registration_nr,email,contact_person,contact_number,companies_not_paid,amount_not_paid) values ('$comp_name','$comp_regnr','$comp_email','$comp_contact_person','$comp_contact_nr','1','$outstandamount')"; if ($num_comp ==1) $query = "update debtor set companies_not_paid = companies_not_paid + 1, amount_not_paid = amount_not_paid + '$outstandamount' where d_name='$comp_name'"; if (mysql_query($query)) { echo "<script>alert('Company Added Successful')</script>"; } $complain_id = "select complainant_id from complainant where email = '$log'"; $run2=mysql_query($complain_id); echo $run2; $query2 = "insert into complaint(complain,d_name,complainant_id) values ('$complain_det','$comp_name','$run2')"; if (mysql_query($query2)) { echo "<script>alert('Complaint Added Successful')</script>"; } } ?> There is also a complainant table which consist of a complainant_id, email and password.
  12. Thank you got the problem, had error with my foreign key
  13. This is how i changed it, if it is not done correctly can you maybe help me, im new to php. <html> <head> <title> Registration Form </title> </head> <body> <form method='post' action='registration.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Registration Form</h1></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' /></td> </tr> <tr> <td>Company Name:</td> <td><input type='text' name='company' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='submit' value='Sign Up' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root","mj2015"); mysql_select_db("whodidntpay"); if(isset($_POST['username'])){ var_dump($_POST); } if(isset($_POST['submit'])) { $com_username = $_POST['username']; $com_password = $_POST['password']; $com_email = $_POST['email']; $com_companyname = $_POST['company']; if($com_username=='') { echo "<script>alert('Please Enter Username')</script>"; exit(); } if($com_password=='') { echo "<script>alert('Please Enter Password')</script>"; exit(); } if($com_email=='') { echo "<script>alert('Please Enter Email')</script>"; exit(); } if($com_companyname=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } $check_email = "select * from complainant where email='$com_email'"; $run = mysql_query($check_email) or die(mysql_error()); if(mysql_num_rows($run)>0) { echo"<script>alert('Email $com_email already exists, please try another email')</script>"; exit(); } $query = "insert into complainant(username,password,c_name,email) values ('$com_username','$com_password','$com_email','$com_companyname')"; if (mysql_query($query)) { echo "<script>alert('Registration Successful')</script>"; } } ?> This is what I get on the screen after entering information: and pressing signup: array (size=5) 'username' => string 'Martin' (length=6) 'password' => string 'mj2015' (length=6) 'email' => string 'martinpark02@gmail.com' (length=22) 'company' => string 'Baas' (length=4) 'submit' => string 'Sign Up' (length=7)
  14. Can somebody tell me why my data is not stored in the database whodidntpay in the table complainant. When entering it in the webpage and sign up button is selected it is suppose to add it to the db. <html> <head> <title> Registration Form </title> </head> <body> <form method='post' action='registration.php'> <table width='400' border='5' align='center'> <tr> <td align='center' colspan='5'><h1>Registration Form</h1></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='username' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' /></td> </tr> <tr> <td>Company Name:</td> <td><input type='text' name='company' /></td> </tr> <tr> <td colspan='5' align='center'><input type='submit' name='submit' value='Sign Up' /></td> </tr> </table> </form> </body> </html> <?php mysql_connect("localhost","root","mj2015"); mysql_select_db("whodidntpay"); if(isset($_POST['submit'])) { $com_username = $_POST['username']; $com_password = $_POST['password']; $com_email = $_POST['email']; $com_companyname = $_POST['company']; if($com_username=='') { echo "<script>alert('Please Enter Username')</script>"; exit(); } if($com_password=='') { echo "<script>alert('Please Enter Password')</script>"; exit(); } if($com_email=='') { echo "<script>alert('Please Enter Email')</script>"; exit(); } if($com_companyname=='') { echo "<script>alert('Please Enter Company Name')</script>"; exit(); } $check_email = "select * from complainant where email='$com_email'"; $run = mysql_query($check_email); if(mysql_num_rows($run)>0) { echo"<script>alert('Email $com_email already exists, please try another email')</script>"; exit(); } $query = "insert into complainant(username,password,c_name,email) values ('$com_username','$com_password','$com_email','$com_companyname')"; if (mysql_query($query)) { echo "<script>alert('Registration Successful')</script>"; } } ?>
×
×
  • 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.