Jump to content

fbm

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fbm's Achievements

Member

Member (2/5)

0

Reputation

  1. cheers huggiebear got there through trial and error lol
  2. solved i was selecting my clients table on the invoice list rather than my invoice table changed $result to $result = mysql_query("SELECT * FROM invoices WHERE `id` = '".$_SESSION['id']."'"); now pulls invoices from the DB which have the ID = to the client session ID
  3. would i need some form of Javascript to reload the page after selecting a client from the drop down box? I'm thinking about the second option having the first page set to select the client then pass it to the next page where the invoice is then created. If it is possible to do it on 1 pge with a reload happenign after a client is selected that would be better but dont want to get involved with Javascript just yet Cheers
  4. Hi, I have 2 tables in my DB [clients] [invoices] Clients table has an ID field set to primary key so each client has a unique ID. On invoice table i pass the unique ID by selecting the client from a drop down list when creating the invoice. The ID is added to the DB correclty. I'm now trying to pull out data which is relevent to the ID stored in the session. Clients login ID is added to session. At the moment my code just pulls out all teh invoices listed and not ID specific rows My code is <?php session_start();?> <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Clients Invoices</h1> <div id="client_list_table"> <table width="860" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="id">ID</td> <td class="company">Company</td> <td class="contact">Contact Name</td> <td class="email">Email</td> <td class="phone">Phone</td> <td class="actions">Actions</td> </tr> <?php $result = mysql_query("SELECT * FROM invoices ORDER BY id ASC"); while($row = mysql_fetch_array($result)) { echo "<tr>\n"; echo "<td class='row_id'>".$row['id']."</td>\n"; echo "<td class='row'>".$row['date']."</td>\n"; echo "<td class='row'>".$row['invoice_number']."</td>\n"; echo "<td class='row'>".$row['title']."</td>\n"; echo "<td class='row'>".$row['value']."</td>\n"; echo "<td class='row'>".$row['pdf']."</td>\n"; echo "<td class='row'>".$row['status']."</td>\n"; echo "</tr>\n"; } ?> </table> </div> </div> </div> <?php include "includes/footer.php"; ?> Any ideas?
  5. hi, I have a DB with 2 tables [clients] [invoices] My clients table is populated with a bunch of data and the primary key is set to an ID field. Now im trying to create the page where i create an invoice but getting a bit stuck. I want the invoice im creating to know which client ID to be stored against so i added a drop down list option in my form which allows me to select my client and it works great the invoice is added using the below code and the ID is pulled from the drop down selection. My question is how do i get more info out of the drop down list, i want the ID and Company name to be pulled from the client table whilst im creating an invoice. here is the code i use for creating an invoice <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Invoices</h1> <form name="form" method="POST" action="process_add_invoice.php"> <div id="add_client_box"> <h1> </h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Select : </td> <td class="right"> <select name="id" style="vertical-align:middle; width:180px;"> <?php $result = mysql_query("SELECT * FROM clients ORDER BY company ASC"); while($row = mysql_fetch_array($result)) { echo "<option value=".$row['id'].">".$row['company']."</option>"; } ?> </select> </td> </tr> <tr> <td height="34" class="left"> </td> <td class="right"> </td> </tr> <tr> <td class="left">date : </td> <td class="right"><input class="field" type="text" name="date" /></td> </tr> </table> </div> <div id="add_client_box"> <h1> </h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">company : </td> <td class="right"> </td> </tr> <tr> <td class="left">invoice number : </td> <td class="right"><input class="field" type="text" name="invoice_number" /></td> </tr> <tr> <td class="left">title : </td> <td class="right"><input class="field" type="text" name="title" /></td> </tr> <tr> <td class="left">value : </td> <td class="right"><input class="field" type="text" name="value" /></td> </tr> <tr> <td class="left">status : </td> <td class="right"><input class="field" type="text" name="status" /></td> </tr> </table> </div> <div id="add_client_box"> <h1> </h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">pdf : </td> <td class="right"><input class="field" type="text" name="pdf" /></td> </tr> <tr> <td class="left"> </td> <td class="right"> </td> </tr> <tr> <td class="left"> </td> <td class="right"> </td> </tr> </table> </div> <div id="add_account_box"><input class="button" value="ADD INVOICE" type="submit" /></div> </form> </div> </div> <?php include "includes/footer.php"; ?> and here is the code which processes the invoice <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <?php $id = $_POST['id']; $date = $_POST['date']; $invoice_number = $_POST['invoice_number']; $title = $_POST['title']; $value = $_POST['value']; $pdf = $_POST['pdf']; $status = $_POST['status']; $query = "INSERT INTO `invoices`(`id`,`date`,`invoice_number`,`title`,`value`,`pdf`,`status`)VALUES('".$id."','".$date."','".$invoice_number."','".$title."','".$value."','".$pdf."','".$status."')"; mysql_query($query) or die(mysql_error()); echo "<center>"; echo "<h1>Adding Invoice to Database, Please Wait</h1>"; echo "<META HTTP-EQUIV=Refresh CONTENT='5; URL=invoices.php'> "; echo "</center>"; ?> </div> <?php include "includes/footer.php"; ?> any ideas how to add more data to the form without having multiple drop downs. all i need is the drop down to support both ID and Company name so that these 2 fields are passed into the invoice table. Cheers
  6. SOLVED : i changed the $_GET to $_SESSION in teh query and it gets the correct details based on teh ID which is passed in the session. Woohooo!!!! thank you very much
  7. now trying to get the full client info from teh DB on teh landing page. Here is the full landing page <?php session_start();?> <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Welcome back <?php echo $_SESSION['username'];?></h1> <?php $result = mysql_query("SELECT * FROM clients WHERE `id` = '".$_GET['id']."'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <div id="add_client_box"> <h1>Account Details</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Company : </td> <td class="right"><?php echo $row['company'];?></td> </tr> <tr> <td class="left">Account No : </td> <td class="right"><?php echo $row['account_number'];?></td> </tr> <tr> <td class="left">Website : </td> <td class="right"><?php echo $row['website'];?></td> </tr> </table> </div> <div id="add_client_box"> <h1>Company Address</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Building Number : </td> <td class="right"><?php echo $row['building_number'];?></td> </tr> <tr> <td class="left">Street : </td> <td class="right"><?php echo $row['street'];?></td> </tr> <tr> <td class="left">City : </td> <td class="right"><?php echo $row['city'];?></td> </tr> <tr> <td class="left">County : </td> <td class="right"><?php echo $row['county'];?></td> </tr> <tr> <td class="left">Post Code : </td> <td class="right"><?php echo $row['post_code'];?></td> </tr> </table> </div> <div id="add_client_box"> <h1>Primary Contact</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Primary Contact : </td> <td class="right"><?php echo $row['primary_contact'];?></td> </tr> <tr> <td class="left">Primary Email : </td> <td class="right"><?php echo $row['primary_email'];?></td> </tr> <tr> <td class="left">Primary Phone : </td> <td class="right"><?php echo $row['primary_phone'];?></td> </tr> </table> </div> <div id="add_client_box"> <h1>Billing Contact</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Billing Contact : </td> <td class="right"><?php echo $row['billing_contact'];?></td> </tr> <tr> <td class="left">Billing Email : </td> <td class="right"><?php echo $row['billing_email'];?></td> </tr> <tr> <td class="left">Billing Phone : </td> <td class="right"><?php echo $row['billing_phone'];?></td> </tr> </table> </div> <div id="add_client_box"> <h1>User Credentials</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Username : </td> <td class="right"><?php echo $row['username'];?></td> </tr> <tr> <td class="left">Password : </td> <td class="right"><?php echo $row['password'];?></td> </tr> </table> </div> <div id="add_account_box"></div> </div> </div> <?php } ?> </div> </div> <?php include "includes/footer.php"; ?> I now get an undefined index again which i assume is because query is wrong or i need to add the ID from teh session somewhere on teh page so it knows what the ID is in the query. Any ideas? Cheers again
  8. cool thanks, now works and shows the Username on login now how do i add other Client data to the session such as the client id?
  9. hi, I am working on a login page for my system. I have a DB all setup which holds client details including the Username and Password. I have this on my login page <?php session_start();?> <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Welcome</h1> <form action="processlogin.php" method="POST"> <table cellspacing="10"> <tr><td><p>User ID:</td><td><input class="box" type="text" name="username"></td></tr> <tr><td><p>Password:</td><td><input class="box" type="password" name="password"></td></tr> <tr><td colspan="2"><input type="submit" value="Login"></td></tr> </table> </form> </div> </div> <?php include "includes/footer.php"; ?> header includes the config.php file and DB connection is all workign fine I then have this on my processlogin.php page <?php $username = $_POST["username"]; $password = $_POST["password"]; include "includes/config.php"; $sql="SELECT * FROM clients WHERE username='$username' and password='$password'"; $r = mysql_query($sql); if(!$r) { $err=mysql_error(); print $err; exit(); } if(mysql_affected_rows()==0){ echo "<p>The username or password you have entered is incorrect!</p>"; echo "<META HTTP-EQUIV=Refresh CONTENT='4; URL=index.php'> "; exit(); } else{ $_SESSION["username"] = $username; echo "<div align='center'><h5>Logging In</h5></div>"; echo "<META HTTP-EQUIV=Refresh CONTENT='2; URL=client_home.php'> "; } ?> i then have this on my landing page after log in is processed <?php session_start();?> <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Welcome back <?php echo $_SESSION['username'];?></h1> </div> </div> <?php include "includes/footer.php"; ?> after logging in i get the following error Notice: Undefined index: username in C:\wamp\www\fbmcrm\clients\client_home.php on line 6 i think the username is not being passed properly in the session. I am trying to acheive a landing page which simply generates a welcome message saying welcome back (username) to start with and the username is specific to the login details used. Any ideas?
  10. Cheers dragon for confirming my DB structure and plans. I have created my client directory and index.php page with login form. Can anyone offer any guidance on how to process the login for and create the session? Cheers Rick
  11. Hi, I have been creating a few posts today but i hope by me creating new ones with new relevent titles is the correct way of doing things. Once one post has been solved i mark it as solved and post my thank you comments. I then move onto another area of my project which has a new issue and really requires a new post title which is relevent to the new question so being new here i hope creating a new relevent post is the best way to do things. Now onto my next question So i am developing my first PHP application and basing it around a CRM application which i plan to use with my clients. I want it to be simple but expandable as my first project i don't want to attempt anything hugely out of my reach as a begginer to PHP. I have my first steps completed - I have a DB with a table of clients info. - I have the ability to add, edit, delete my clients from an admin area. Next Step is to understand how to handle client specific information I want to create an invoice section on my backend. This will be a simple form which i should be able to manage with my current skills. The form will consist of, client dropdown list to select a client, then the following fields, [date], [invoice number], [invoice title], [invoice value], [status] and a browse button to upload a PDF copy of the invoice which i create from another system external to this CRM. So my questions 1. Creating the invoice table the right way? the end result will be an admin area where i login into and add invoices and a front end where my clients can login to view invoices relevent to them. 2. How do i tie the invoice data to the client account. In my client table i have setup the primary key as the ID and i am assuming by selecting my client from a drop down list when creating the invoice i will be able to add the clients ID into the invoice table making the client ID still the primary key. Does this sound like the best way to do it? everythign client specific should be linked to the client ID. 3. So once i complete the backend invoice tables and have the ebility to add invoices i will be moving onto the front end for the first tests. I have read that sessions are the best way to handle users logging in. After logging in i will want to show invoices relevent to there ID. Does my above plans cover this ability or should i change my plans now to avoid any problems? 4. I would like to create my first front end test which will be a login form and after logging in it just lists the clients info which is populated in the clients table relevent to the login details used. Where is a good place to start with this? i am thinkign by lookign at the frotn end approach now it may help me understand the process better and allow me to cater for future plans in the DB structure. Cheers
  12. Another outstanding and fast response which has solved the issue. woohoo view, edit and delete buttons now all works wonderfully. Hmm now the easy bit is all sorted need to move onto more advanced stuff, yikes!!! Thanks for the fix guys. Anyone use Skype and interested in working with me on a small CRM system. I really want to build the system myself and learn alot abotu PHP but small questions liek above will always pop up which it would be good to have a contact available to me who is interested in challenges. The CRM system is not a commercial product. I am building it for my own customers and am hoping to offer it as an open source system once its all finished.
  13. Hi Again I am now trying to edit data already stored in my DB. My data is populated on a page called client_list.php and code looks like this <table width="860" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="id">ID</td> <td class="company">Company</td> <td class="contact">Contact Name</td> <td class="email">Email</td> <td class="phone">Phone</td> <td class="actions">Actions</td> </tr> <?php $result = mysql_query("SELECT * FROM clients ORDER BY id ASC"); while($row = mysql_fetch_array($result)) { echo "<tr>\n"; echo "<td class='row_id'>".$row['id']."</td>\n"; echo "<td class='row'>".$row['company']."</td>\n"; echo "<td class='row'>".$row['primary_contact']."</td>\n"; echo "<td class='row'><a href='mailto:".$row['primary_email']."'>".$row['primary_email']."</a></td>\n"; echo "<td class='row'>".$row['primary_phone']."</td>\n"; echo "<td class='row'>\n"; echo "<ul>\n"; echo "<li class='view'><a href='clients_view.php?id=".$row['id']."'><span>view</span></a></li>\n"; echo "<li class='edit'><a href='clients_edit.php?id=".$row['id']."'><span>edit</span></a></li>\n"; echo "<li class='delete'><a href='process_delete_client.php?id=".$row['id']."'><span>delete</span></a></li>\n"; echo "</ul>\n"; echo "</td>\n"; echo "</tr>\n"; } ?> </table> Using the edit button which you can see at the bottom of the above code it links me to http://localhost/fbmcrm/manage/clients_edit.php?id=4 clients_edit.php looks like this <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <h1>Add Clients</h1> <?php $result = mysql_query("SELECT * FROM clients WHERE `id` = '".$_GET['id']."'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?> <form name="form" method="POST" action="process_edit_client.php"> <div id="add_client_box"> <h1>Account Details</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Company : </td> <td class="right"><input class="field" type="text" name="company" value="<?php echo $row['company'];?>" /></td> </tr> <tr> <td class="left">Account No : </td> <td class="right"><input class="field" type="text" name="account_number" value="<?php echo $row['account_number'];?>"/></td> </tr> <tr> <td class="left">Website : </td> <td class="right"><input class="field" type="text" name="website" value="<?php echo $row['website'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>Company Address</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Building Number : </td> <td class="right"><input class="field" type="text" name="building_number" value="<?php echo $row['building_number'];?>" /></td> </tr> <tr> <td class="left">Street : </td> <td class="right"><input class="field" type="text" name="street" value="<?php echo $row['street'];?>" /></td> </tr> <tr> <td class="left">City : </td> <td class="right"><input class="field" type="text" name="city" value="<?php echo $row['city'];?>" /></td> </tr> <tr> <td class="left">County : </td> <td class="right"><input class="field" type="text" name="county" value="<?php echo $row['county'];?>" /></td> </tr> <tr> <td class="left">Post Code : </td> <td class="right"><input class="field" type="text" name="post_code" value="<?php echo $row['post_code'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>Primary Contact</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Primary Contact : </td> <td class="right"><input class="field" type="text" name="primary_contact" value="<?php echo $row['primary_contact'];?>" /></td> </tr> <tr> <td class="left">Primary Email : </td> <td class="right"><input class="field" type="text" name="primary_email" value="<?php echo $row['primary_email'];?>" /></td> </tr> <tr> <td class="left">Primary Phone : </td> <td class="right"><input class="field" type="text" name="primary_phone" value="<?php echo $row['primary_phone'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>Billing Contact</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Billing Contact : </td> <td class="right"><input class="field" type="text" name="billing_contact" value="<?php echo $row['billing_contact'];?>" /></td> </tr> <tr> <td class="left">Billing Email : </td> <td class="right"><input class="field" type="text" name="billing_email" value="<?php echo $row['billing_email'];?>" /></td> </tr> <tr> <td class="left">Billing Phone : </td> <td class="right"><input class="field" type="text" name="billing_phone" value="<?php echo $row['billing_phone'];?>" /></td> </tr> </table> </div> <div id="add_client_box"> <h1>User Credentials</h1> <table width="404" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="left">Username : </td> <td class="right"><input class="field" type="text" name="username" value="<?php echo $row['username'];?>" /></td> </tr> <tr> <td class="left">Password : </td> <td class="right"><input class="field" type="text" name="password" value="<?php echo $row['password'];?>" /></td> </tr> </table> </div> <div id="add_account_box"><input class="button" value="UPDATE" type="submit" /></div> </form> </div> </div> <?php include "includes/footer.php"; ?> I basically copied the form i use to add a client but grabbed the ID and give the form fields the value set to populate the form. the form action is set to go too process_edit_client.php and this page contains <?php include "includes/header.php"; ?> <div id="page_content"> <div id="sub_menu"></div> <div id="content"> <?php $id = $_GET['id']; $company = $_POST['company']; $account_number = $_POST['account_number']; $website = $_POST['website']; $building_number = $_POST['building_number']; $street = $_POST['street']; $city = $_POST['city']; $county = $_POST['county']; $post_code = $_POST['post_code']; $primary_contact = $_POST['primary_contact']; $primary_email = $_POST['primary_email']; $primary_phone = $_POST['primary_phone']; $billing_contact = $_POST['billing_contact']; $billing_email = $_POST['billing_email']; $billing_phone = $_POST['billing_phone']; $username = $_POST['username']; $password = $_POST['password']; $query = "UPDATE `clients` SET `company` = '$company', `account_number` = '$account_number', `website` = '$website', `building_number` = '$building_number', `street` = '$street', `city` = '$city', `county` = '$county', `post_code` = '$post_code', `primary_contact` = '$primary_contact', `primary_email` = '$primary_email', `primary_phone` = '$primary_phone', `billing_contact` = '$billing_contact', `billing_email` = '$billing_email', `billing_phone` = '$billing_phone', `username` = '$username', `password` = '$password' WHERE `id` = '$id'"; mysql_query($query) or die(mysql_error()); } echo "<center>"; echo "<h1>Updating Client Details, Please Wait</h1>"; echo "<META HTTP-EQUIV=Refresh CONTENT='5; URL=clients_list.php'> "; echo "</center>"; ?> </div> <?php include "includes/footer.php"; ?> So now when i click the edit button from my table list of clients i get a parse error Parse error: parse error in C:\wamp\www\fbmcrm\manage\clients_edit.php on line 107 Line 107 was the include footer line but when i remove this the line number just goes to the previous line so not sure where i'm going wrong.
  14. thanks guys, now working Onto the edit and view pages now
×
×
  • 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.