Jump to content

mattichu

Members
  • Posts

    38
  • Joined

  • Last visited

About mattichu

  • Birthday 09/11/1988

Profile Information

  • Gender
    Male
  • Location
    UK

mattichu's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Thanks that makes sense, I am using the system to email unique voucher codes upon the submission of customer details. I have chosen to append the database record ID to the beginning of the code so that they can never be the same. Thanks for your help!
  2. Hi Probably a simple solution to this: I need to check if a randomly generated string is already in the database, if it is I need to generate another one until a unique one is found. How do I go about implementing this? I have the following code: <?php $name=$_POST['name']; $mobile=$_POST['mobile']; $email=$_POST['email']; $name=ucwords($name); $email=strtolower ($email); function randStrGen($len){ $result = ""; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $charArray = str_split($chars); for($i = 0; $i < $len; $i++){ $randItem = array_rand($charArray); $result .= "".$charArray[$randItem]; } return $result; } $randstr = randStrGen(5); $code=$randstr; $servername = "********"; $username = "******"; $password = "******"; $dbname = "******"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM freedrink WHERE code='$code'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // Need a loop somehow } Thanks!
  3. Hi! Im using the following code to change an image from a tick to a cross: <script type="text/javascript"> imgs=Array("/new4/images/allow.png","/new4/images/deny.png"); var x=0; function change() { document.getElementById("bob").src=imgs[++x]; if (x==1) { x=-1; } } </script> <img id="bob" height="20" width="20"src="/new4/images/allow.png" onmousedown="change()"> How would I go about storing the option the user has left it on in an SQL database? any help much appreciated!
  4. I'm a total noob with java script and have found some code to open an upload dialogue when a link is clicked. How/where do I insert the code which will actually upload the file to the server? <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('#uploadFile').click(function(e) { $('#fileUploadField').click(); e.preventDefault(); }); }); </script> <input type="file" name="something" style="display: none" id="fileUploadField" /> <a href="" id="uploadFile">Upload File</a> Any Help much appreciated
  5. nice one, and how would I go about doing this?
  6. after much googling I still can find a solution Is it possible to update an sql database with the textbox value when its changed or no longer in focus? cheers!
  7. hello! I have a page which uses some code from dot mailer.co.uk to add a users data into their address book, once that has been done I would like the page to redirect to a thank you page. Problem is nothing after that code seems to process. for example: $addressbookid=****; $email = $email; $AudienceType="B2B"; $OptInType="Single"; $EmailType="Html"; $FirstName = $firstname; $LastName=$lastname; $Mobile = $mobile; $notes = "This person made a table booking" ; $keys = array("FIRSTNAME","LASTNAME","MOBILE"); $var1 = new SoapVar($FirstName,XSD_STRING,"string","http://www.w3.org/2001/XMLSchema"); //Create an instance of SoapVar for each one of the values $var2 = new SoapVar($LastName,XSD_STRING,"string","http://www.w3.org/2001/XMLSchema"); $var3 = new SoapVar($Mobile,XSD_STRING,"string","http://www.w3.org/2001/XMLSchema"); $values = array($var1,$var2,$var3); $Datafields = array ('Keys'=>$keys,'Values'=>$values); $contact = array ("Email"=>$email,"AudienceType"=>$AudienceType,"OptInType"=>$OptInType,"EmailType"=>$EmailType,"ID"=>-1,"DataFields"=>$Datafields,"Notes"=>$notes); $params = array ("username"=>$username,"password"=>$password,"contact"=>$contact,"addressbookId"=>$addressbookid); return $client->AddContactToAddressbook($params); echo "test"; the echo at the end doesn't do anything, any ideas why?
  8. Hi I have a table: ------------------------------------------------------------------------------------------ ID | DATE | Staff1 | Staff2 | Staff3 | venue | ------------------------------------------------------------------------------------------ 1 1st Jan 10-cl 11-cl OFF xx 2 2nd Jan 11-cl 10-cl 10-cl xx 3 3rd Jan 10-cl 11-cl OFF xx 4 4th Jan 11-cl 10-cl 10-cl xx 5 5th Jan 10-cl 11-cl OFF xx 6 6thJan 11-cl 10-cl 10-cl xy How would I swap the contents in staff 1 and 2 AFTER the 2nd jan? any help much appreciated! ^^
  9. Thanks Psycho, exactly what I was after. much appreciated!
  10. heyy I have a form which validates by posting the form to itself so that when the page reloads the values the user input are posted back into the text boxes. How do I make it so that the posted drop down selection is the selected item on the reload??
  11. I've changed the code to: $dayoff=$_POST['dayoff']; $date=date("dS M Y",$dayoff); But this gives: 31st Dec 1969 $dayoff outputs correctly
  12. Hi, Im posting a date in the format : dd/mm/yyyy and am wanting to store it in a database as a string. I'm using the following code: $dayoff=$_POST['dayoff']; $dayoffst=strtotime('$dayoff'); $date=date('dS M Y',$dayoffst); However when I echo the $dayoffst it doesn't return anything any ideas?
  13. Hi, I have written a PHP clocking in system for staff to use. The user inputs their pin and the time they clocked in/out is recorded in an SQL database on the server. Ive found that the browser (firefox) occasionaly gets stuck when a user presses enter (maybe a dodgy internet connection) and prevents anyone else clocking in until refresh is pressed. Is there a way to store the data locally then upload it to the server every so often? or another way to fix this issue? many thanks!
×
×
  • 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.