Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by princesohrab

  1. it works now.. Ive figured it out..It was to do with setting the keys..Im very new to this.. sorry to be a pain guys
  2. Ok thanks.. Where do I put this mysqli_error() to get the error message?
  3. Hi Birbal,In my table called "people" I created through MySql,I have 3 columns:peopleid (auto increment)firstnamelastname which one should be primary key? At the moment,peopleid and firstname fields are as primary key. Im trying to set only the peopleid as primary but for some reason it wont let me.
  4. Oh, I get the error message which I echoed in the statement.. Error inserting new record but only if there's one entry saved on the database already..
  5. I have created the table with 3 columns..peopleidfirstnamelastnameI believe I have them all as primary key.. (I'm not home, on the way to work)Which one should be primary key?Only peopleid?? peopleid is auto increment and was defined as medium integer..The code seems fine.. I think it's to do with the structure if the table..I'm not sure..I will reset a table and please let me know which one to use as primary.Thanks
  6. Hi all,Im am trying to use a web form to send data to a table called "people" in my database using php.The script store the first time you submit the for and the data goes to the correct table too. The problem is it only allows you to do it only once meaning only 1 entry is registrered. If I try again, I get error message. Then i delete the entry from the database, I refresh the form, send again and it registers. I just need to know how to make it register more than one person's details. Below is the code <?phpif (isset($_POST['submitted'])) {include('w-hill-reg-form-database-connect.php');$fname = $_POST['fname'];$lname = $_POST['lname'];$sqlinsert = "INSERT INTO people (firstname, lastname) VALUES ('$fname', '$lname')";if (!mysqli_query($dbcon, $sqlinsert)) { die ('Error inserting new record');}$newrecord = "New record added";}?><html><head><title>CALLING ALL TENNIS PLAYERS!</title></head><body><form method="post" action="w-hill-registration-form-php.php"><input type="hidden" name="submitted" value="true" /><fieldset><legend>New People</legend> <label>First Name: <input type="text" name="fname" /></label> <label>Last Name: <input type="text" name="lname" /></label></fieldset><br/><input type="submit" value="Add new person" /></form><?phpecho $newrecord // New record added statement added at the top?></body></html>
  7. I just had to put the define host first
  8. Hey sorry guys.. Ive done itthanks
  9. hi all, wondering if you would be able to help me..im trying to connect to my database but i keep getting the error message which i echo in the page <?php DEFINE('DB_USER', 'ok');DEFINE('DB_PASSWORD', 'ok');DEFINE('DB_HOST', 'ok.com.mysql');DEFINE('DB_NAME', 'o_co');$dbconnect = mysql_connect(DB_USER, DB_PASSWORD, DB_HOST, DB_NAME);if (!$dbconnect) {die('Error connecting to the database');} echo 'You have connected successfully';?>
  10. The one thing Im lost on is creating the CSV file..Does that file stay opn the server? Do I create it with Excel? Then how to link the 2 together?
  11. Thanks.. Appreciate it..I will do it step by step and if I get stuck, Ill get back to you.I found a few tutorials and hopefully Ill get my head around it.Thanks
  12. That is exacly what needs to be done.. But I am more of a front end guy..Im not too sure how to proceed about it.Your help is greatly appreciated. I found this tutorial Not sure if its the same thing..I really need to figure this out.
  13. Hi all,Online registration form which allow users to fill in their details and send the data by submitting the form to my email using php.I need to create an online registration form and when the form is submitted, the data needs to go in to a spreadsheet in (MS EXCEL). Maybe a database I guess..The data should be able to be accessed at any time and read by a spreadsheet by someone in the office. Someone sent me this code $df = fopen("php://output", 'w'); fputcsv($df, array_keys(reset($array))); foreach ($_POSTas $row) { fputcsv($df, $row); } fclose($df); Can anyone help me as to where and how I use this snippet to get it to work. Basically the form data needs to be written into a CSV file. Here is the form: <form action="http://www.sohrabgoodar.com/w-hill-contactformprocess.php" method="post" id="comments_form"><div class="row"> <div class="label">Name</div><!--end .label--> <div class="input"> <input type="text" for="name" id="name" class="detail" name="name" /> </div><!--end .input--> </div><!--end .row--> <div class="row"> <div class="label">Work Location</div><!--end .label--> <div class="input"> <input type="text" for="worklocation" id="worklocation" class="detail" name="worklocation" /> </div><!--end .input--> </div><!--end .row--> <div class="row"> <div class="label">Work Contact Number</div><!--end .label--> <div class="input"> <input type="text" for="worknumber" id="worknumber" class="detail" name="worknumber" /> </div><!--end .input--> </div><!--end .row--> <div class="row"> <div class="label">Mobile Contact Number</div><!--end .label--> <div class="input"> <input type="text" for="mobile" id="mobile" class="detail" name="mobile" /> </div><!--end .input--> </div><!--end .row--> <div class="row"> <div class="label">Email Address</div> <!--end .label--> <div class="input"> <input type="text" for="email" id="email" class="detail" name="email" /> </div><!--end .input--> </div><!--end .row--> <div class="row"> <div class="label">Ability Level</div> <!--end .label--> <div class="input3"> <select name="ability" for="ability" id="ability" class="detail"> <option>Please Choose</option> <option value="strong">Strong</option> <option value="medium">Medium</option> <option value="weak">Weak</option> </select> </div><!--end .input3--> </div><!--end .row--> <div class="row"> <div class="label">Tennis Standard</div> <!--end .label--> <div class="input3"> <select name="standard" for="standard" id="standard" class="detail"> <option>Please Choose</option> <option value="school">School</option> <option value="club">Club</option> <option value="county">County</option> <option value="international">International</option> </select> </div><!--end .input3--> </div><!--end .row--> <div class="row"> <div class="label">Frequency of Play</div> <!--end .label--> <div class="input3"> <select name="frequency" for="frequency" id="frequency" class="detail"> <option>Please Choose</option> <option value="weekly">Weekly</option> <option value="monthly">Monthly</option> <option value="fewtimes">Few Times a Year</option> </select> </div><!--end .input3--> </div><!--end .row--> <div class="row"> <div class="label2">Anything else you would like to tell us?</div><!--end .label2--> <div class="input2"> <textarea id="comment" name="comment" class="mess"></textarea> </div><!--end .input--> </div><!--end .row--> <div class="submit"> <input type="submit" id="submit" name="submit" value="Send Message" /> </div><!--end .submit--></form> Here is the old php file I was using to send the form data to emails. <?php $emailSubject = 'Tennis Registration!';$webMaster = 'someone@yahoo.co.uk';$nameField = $_POST['name'];$worklocationField = $_POST['worklocation'];$worknumberField = $_POST['worknumber'];$mobileField = $_POST['mobile'];$emailField = $_POST['email'];$abilityField = $_POST['ability'];$standardField = $_POST['standard'];$frequencyField = $_POST['frequency'];$commentField = $_POST['comment'];$body = <<<EOD<br><hr><br>Name: $nameField <br>Work location: $worklocationField <br>Work Number: $worknumberField <br>Mobile: $mobileField <br>Email: $emailField <br>Ability: $abilityField <br>Standard: $standardField <br>Frequency: $frequencyField <br>Comment: $commentField <br>EOD;$headers = "From: $email\r\n";$headers .= "Content-type: text/html\r\n";$success = mail($webMaster, $emailSubject, $body, $headers);$theResults = <<<EOD<p>Thank you for your Message! You will be redirected to the home page in a moment</p><script type="text/javascript" >setTimeout ('ourRedirect()', 3000)function ourRedirect(){ location.href='http://www.google.com/'}</script>EOD;echo "$theResults";?>
  14. ok.. I want it to write to an XLS file. How do i set up that file on the server andWhat are the functions on the PHP file?Have you got an example please? Im in real trouble as I need to get that done by tomorrow morning. this task is part of a recruitment process. Basically they told me: (Set up an “apply online” functionality – so that the person who review the data can get all the information he needs to get a team together. This should be provided on an excel spreadsheet) They also said: (It is not useful for members of the management team to receive emails every time someone applies in these circumstances so we usually have functionality which transfers the information into an excel spreadsheet so once the closing date) has passed we return the necessary data on this.
  15. This is where I got the snippet http://www.lateralcode.com/excel-spreadsheets-php/
  16. how do I name the file so that I can call it from the contact form? ie: form action
  17. Im overwhelmed.. :sorry:This is what i found on how to start it in php. <?phpheader( "Content-Type: application/vnd.ms-excel" );header( "Content-disposition: attachment; filename=spreadsheet.xls" );// print your data here. note the following:// - cells/columns are separated by tabs ("\t")// - rows are separated by newlines ("\n")// for example:echo 'First Name' . "\t" . 'Last Name' . "\t" . 'Phone' . "\n";echo 'John' . "\t" . 'Doe' . "\t" . '555-5555' . "\n";?> Do I declare the variable the same way as I did with the PHP file i pasted earlier?
  18. I have never worked with spreadsheet before and not sure how to proceed. <form id="form1" method="post" action="w-hill-contactformprocess.php">
  19. This is the html code for the form and below it is the PHP code I was thinking of using so the data can be sent to an email address.But they want it to be stored and be able to read on spreadsheet excel. <form id="form1" method="post" action="w-hill-contactformprocess.php"> <table width="90%" border="0" align="center" cellpadding="6" cellspacing="2" onfocus="MM_validateForm('name','','R','email','','RisEmail','telephone','','NisNum');return document.MM_returnValue"> <tr> <td align="right"><label for="name">Name</label></td> <td align="left"><input name="name" type="text" id="name" size="45" maxlength="30" /></td> </tr> <tr> <td align="right"><label for="worklocation">Work Location</label></td> <td align="left"><input name="worklocation" type="text" id="worklocation" size="45" maxlength="30" /></td> </tr> <tr> <td align="right"><label for="worknumber">Work Contact Number</label></td> <td align="left"><input name="worknumber" type="text" id="worknumber" size="45" maxlength="90" /></td> </tr> <tr> <td align="right"><label for="mobile">Mobile Number</label></td> <td align="left"><input name="mobile" type="text" id="mobile" size="45" maxlength="12" /></td> </tr> <tr> <td align="right"><label for="email">Email Address</label></td> <td align="left"><input name="email" type="text" id="email" size="45" /></td> </tr> <tr> <td align="right"><label for="abilitylevel">Ability Level</label></td> <td align="left"> <select name="Ability"> <option value="Strong">Strong</option> <option value="Medium">Medium</option> <option value="Weak">Weak</option> </select> </td> </tr> <tr> <td align="right"><label for="abilitylevel">Tennis Standard</label></td> <td align="left"> <select name="Standard"> <option value="Strong">School</option> <option value="Medium">Club</option> <option value="Weak">County</option> <option value="Weak">International</option> </select> </td> </tr> <tr> <td align="right"><label for="abilitylevel">Frequency of Play</label></td> <td align="left"> <select name="Ability"> <option value="Strong">Weekly</option> <option value="Medium">Monthly</option> <option value="Weak">Few Times a Year</option> </select> </td> </tr> <tr> <td align="right"><label for="comments">Anything else you would like to tell us</label></td> <td align="left"><textarea name="comments" id="comments" cols="35" rows="6"></textarea></td> </tr> <tr> <td align="right"> </td> <td align="left"><label for="submit"></label> <input name="submit" type="submit" id="submit" onclick="MM_validateForm('email','','RisEmail','telephone','','NisNum');return document.MM_returnValue" value="Submit" /></td> </tr> </table> </form> <?php $emailSubject = 'Tennis Registration!';$webMaster = 'sohrab.goodar@yahoo.com';$nameField = $_POST['name'];$emailField = $_POST['email'];$telephoneField = $_POST['telephone'];$commentsField = $_POST['comments'];$body = <<<EOD<br><hr><br>Name: $nameField <br>Email: $emailField <br>Telephone: $telephoneField <br>Comments: $commentsField <br>EOD;$headers = "From: $email\r\n";$headers .= "Content-type: text/html\r\n";$success = mail($webMaster, $emailSubject, $body, $headers);$theResults = <<<EOD<p>Thank you for your Message! You will be redirected to the home page in a moment</p><script type="text/javascript" >setTimeout ('ourRedirect()', 3000)function ourRedirect(){ location.href='index.html'}</script>EOD;echo "$theResults";?>
  20. Thanks guys.. Do I still use the form action as usual??And is the script a separate file?Have any of you got an example of how it's done?Please help
  21. Thanks guys.. Do I still use the form action as usual??And is the script a separate file?Have any
  22. Hi all.. I need help.I've been asked to create and online registration form and when the form is submitted, the data has to go on a spreadsheet (Excel). I'm assuming a database where the registration details is viewed in Excel Spreadsheet.I have done form to send data to email before but not to Excel spreadsheet..Also, I'm not sure if PHP can be used or ASP.Any help would be greatly appreciated.Many thanks
  23. Hi all,urgent, I need help.I need to set up and online form where people can register their details and I need these details to gointo a speadsheet (Excel).Im asssuming its a database.How do I set that up? I was planning on using php script which grabs the detail and send it to an email but they want it to be sentonto a spreadsheet.I have never done it before and do not have a clue how its done.Can anypne help please.Many thanks
  24. Thanks a lot.. Ive figured it out.. Appreciate the help.
  • Create New...