Jump to content

SalientAnimal

Members
  • Posts

    366
  • Joined

  • Last visited

Everything posted by SalientAnimal

  1. I have done some web design before. But I don't always get the results I want. I've built functional PHP sites as well. Was really only looking for advice on what I should do with my design. I don't want my design to end up like on of my past builds that I didn't really get the result that I had planned previously.
  2. Hi All, I'm looking for some advice on a website I'm busy building for selling things online. I've basically designed the layout I want and how I want it to look in photoshop. A big portion of the layout is a flat image though. What is the best way to incorporate this into an actual website? Is it best to use <table> tags or <div> tags? I have attached a copy of my design as an image. The only thing that is currently missing on this image is a navigation menu at the top. I would really appreciate any help here. Thanks
  3. Hi All, I am stuck at the very first part of my site, and have no idea why I and getting the below error message. I have tried recreating the user in the mysql database with the correct username and password, and even granted full access. I am setting up a site and jsut created an initial default account to test everything is working fine, so din't mind sharing usernames and passwords if need be as I am currently setting up the webserver on a local machine just to test before launching it. Username: test Password: W@t3r Table: test Database: maindb Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'test'@'localhost' (using password: YES) in C:\xampp\htdocs\the_lab\labupload.php on line 8 MySQL connection failed: Access denied for user 'test'@'localhost' (using password: YES) Here the initial part of my code, I am using it to upload files into my database: <?php // Check if a file has been uploaded if(isset($_FILES['uploaded_file'])) { // Make sure the file was sent without errors if($_FILES['uploaded_file']['error'] == 0) { // Connect to the database $dbLink = mysqli_connect("localhost","test","W@t3r","maindb"); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } // Gather all required data $name = $dbLink->real_escape_string($_FILES['uploaded_file']['name']); $mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']); $data = $dbLink->real_escape_string(file_get_contents($_FILES ['uploaded_file']['tmp_name'])); $size = intval($_FILES['uploaded_file']['size']); // Create the SQL query $query = " INSERT INTO `test` ( `name`, `mime`, `size`, `data`, `created` ) VALUES ( '{$name}', '{$mime}', {$size}, '{$data}', NOW() )"; // Execute the query $result = $dbLink->query($query); // Check if it was successfull if($result) { echo 'Success! Your file was successfully added!'; } else { echo 'Error! Failed to insert the file' . "<pre>{$dbLink->error}</pre>"; } } else { echo 'An error accured while the file was being uploaded. ' . 'Error code: '. intval($_FILES['uploaded_file']['error']); } // Close the mysql connection $dbLink->close(); } else { echo 'Error! A file was not sent!'; } // Echo a link back to the main page echo '<p>Click <a href="the_lab.html">here</a> to go back</p>'; ?> I am using Apache, and Windows 7.
  4. Hi All, I'm still look for some help on this. Anyone able to guide me in the right dirrection?
  5. Problem is I already have a company defined number, sms gateway etc setup. And I need to make use of those. I just need help finding out what is wrong with my code and then using it.
  6. I'm not sure if this is what you are after, but try doing your insert something like this: $query="INSERT INTO selection (value_1 , value_2 , radio_selection ) VALUES ('$_POST[value_1]' ,'$_POST[value2_]' ,'$_POST[radiobutton_1], $_POST[radiobutton_2]')";
  7. The other thing that you can use here is a multiple drop-down box. This uses a validation to check the current selected value to then populate the next list. I did this a while ago and was able to have multiple drop-downs all populating based on the previous selection.
  8. Yip, is as basic as having two scripts running on your submit page. But we will have to see examples of what you have tried to assist further.
  9. Hi All, I'm not 100% sure if this is the place to be posting for help with this. I have managed to get some source code for a SMS PHP page. However I am having some problems getting it to work, mainly because I'm not 1005 sure how to configure it, and if I need to make any toher changes to the code in order to incorporate my SMS gateway. The error message I am getting is: "SMS Sending Failed Message:Network error unable to send the message", this mesage is however coded into the code. Below is the code of the 4 different pages: HTML Page where message is created <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>SMS Sending Service</title> <style type="text/css"> body { font-family:Verdana,Arial,sans-serif; font-size:100%; } td { vertical-align:top; } input[type=submit] { padding:5px 10px; } </style> <script type="text/javascript" src="send.js"></script> </head> <body> <h1>SMS Sending Service</h1> <form action="send.php" method="post"> <table border="0" cellpadding="5" style="background:#F7F7F7;border:1px solid #CCC;border-radius:5px;-moz-border-radius:5px;"> <tr> <td><label for="method">Tipo di SMS:</label></td> <td> <select name="method" id="method"> <option value="classic">Classic</option> <option value="report">Classic con notifica</option> <option value="basic">Basic</option> </select> </td> </tr> <tr> <td><label for="recipients">Your Valentine's Number: </label></td> <td> <span id="recipients"> <div><input type="text" name="recipients[]" value="27" /></div> </span> <a href="javascript:;" onclick="addRecipient();"><small>Add Another Valentine</small></a> </td> </tr> <tr> <td><label for="text">Message: </label></td> <td><textarea name="text" id="text" cols="30" rows="10"></textarea></td> </tr> <tr> <td></td> <td> <small> Characters Remaining: <span id="leftChars" style="color:#F00;">0</span> / <b id="messageMaxLength">765</b> (<span id="numberOfSMS" style="color:#39b54a;">1</span>) </small> </td> </tr> <tr> <td><label for="sender_number">Sender's Number: </label></td> <td><input type="text" name="sender_number" id="sender_number" /> <small>Eg 27741123456</small></td> </tr> <tr> <td><label for="sender_string">Alphanumeric Sender: </label></td> <td><input type="text" name="sender_string" id="sender_string" maxlength="11" /> <small>Max 11 Characters</small></td> </tr> <tr> <td><label for="charset">Charset</label></td> <td> <select name="charset" id="charset"> <option value="ISO-8859-1">ISO-8859-1</option> <option value="UTF-8">UTF-8</option> </select> </td> </tr> <tr> <td colspan="2" align="right"> <input type="submit" value="Send Message" name="submit" /> </td> </tr> </table> </form> </body> </html> PHP Send page <?php // IMPORTANT: // ENTER YOUR CREDENTIALS HERE VM ini_set('soap.wsdl_cache_enabled',0); ini_set('soap.wsdl_cache_ttl',0); define('VM_WSDL', 'https://myhostserver/WebsiteData/WebsiteDataEndpoint?wsdl'); define('VM_USERNAME','MyGateWayUsername'); define('VM_PASSWORD','MyGateWayPassword'); require('validate.php'); // Collect post data from form $method = $_POST['method']; $recipients = $_POST['recipients']; $text = $_POST['text']; $sender_number = $_POST['sender_number']; $sender_string = $_POST['sender_string']; $charset = $_POST['charset']; $result = VMGatewaySendSMS(VM_USERNAME, VM_PASSWORD, $recipients, $text, $method, $sender_number, $sender_string, $charset); if($result['status']=='success') { echo '<b style="color:#8dc63f;">SMS Sent Successfully</b><br/>'; echo '<b>SMS rimanenti:</b>'.$result['remaining_sms']; } if($result['status']=='failed') { echo '<b style="color:#ed1c24;">SMS Sending Failed</b><br/>'; if(isset($result['code'])) { echo '<b>Codice:</b>'.$result['code'].'<br/>'; } echo '<b>Message:</b>'.urldecode($result['message']); } ?> Send.js file var SMS_CLASSIC_MAX_LENGTH = 765, SMS_BASIC_MAX_LENGTH = 1404, CURRENT_SMS_LENGTH = 765; var translations = Array(); translations['ErrorTextMoreThan']='Attenzione! Il testo non puo\' essere piu\' lungo di '; translations['ErrorChars']=' caratteri!\n'; function addRecipient() { var newRecipient = document.createElement('div'); newRecipient.innerHTML = '<input type="text" name="recipients[]" value="27" /> <a href="javascript:;" onclick="removeRecipient(this.parentNode);"><small>Remove</small></a>'; document.getElementById("recipients").appendChild(newRecipient); } function removeRecipient(obj) { document.getElementById("recipients").removeChild(obj); } window.onload = function() { var msgMaxLen = document.getElementById("messageMaxLength"); document.getElementById("method").onchange = function(){ switch(this.value) { case "classic": case "report": msgMaxLen.innerHTML = SMS_CLASSIC_MAX_LENGTH; CURRENT_SMS_LENGTH = SMS_CLASSIC_MAX_LENGTH; charLeft(); break; case "basic": msgMaxLen.innerHTML = SMS_BASIC_MAX_LENGTH; CURRENT_SMS_LENGTH = SMS_BASIC_MAX_LENGTH; charLeft(); break; } }; document.getElementById("text").onkeyup = function(){ charLeft(); }; }; function charLeft(){ var max = CURRENT_SMS_LENGTH; var smsText = document.getElementById("text").value; var doubleChars = 0; if(smsText==="") { var length = 0; } else { var length = getRealLengthFor(smsText,false); doubleChars = getRealLengthFor(smsText,true); } if (length > max){ document.getElementById("text").value = smsText.substring(0, max-doubleChars); alert(translations['ErrorTextMoreThan'] + max + translations['ErrorChars']); } var leftChars = length; if (leftChars < 0){ leftChars = 0; } document.getElementById("leftChars").innerHTML = leftChars; var numberOfSMS = document.getElementById("numberOfSMS"); var actualNumberOfSMS = 0; switch(max) { case SMS_CLASSIC_MAX_LENGTH: if(length<=160) { numberOfSMS.innerHTML = '1'; } if(length>160) { actualNumberOfSMS = Math.floor((length-1) / 153) + 1; numberOfSMS.innerHTML = actualNumberOfSMS; } break; case SMS_BASIC_MAX_LENGTH: numberOfSMS.innerHTML = getNumberOfSegmentForBasic(smsText.length, smsText); break; } } //from JAVA: //var SPECIAL_CHARS = Array('[', '\\', ']', '^', '{', '|', '}', '~', '¬', 8364); var SPECIAL_CHARS = Array("\x5B", "\x5C", "\x5D", "\x5E", "\x7B", "\x7C", "\x7D", "\x7E", 8364, 49792, 14844588); var CHAR_TO_CUT_BASIC = Array(' ', '.', ',', '?', '!'); // Fa il check se una variabile e' null o vuota function isEmpty( inputStr ) { if ( null == inputStr || "" == inputStr ) { return true; } return false; } // Aggiungo un metodo alla classe string // toCharArray esistente in java String.prototype.toCharArray = function() { var charArr=new Array(); for(var i=0;i<this.length;i++) charArr[i]=this.charAt(i); return charArr; }; // isIntInTheArray // Cerca nell'array chars se e' presente il carattere c // Parametri: // char c, char[] chars function isIntInTheArray(c, chars) { for(var i=0;i<chars.length;i++) { if(chars[i] == c || chars[i] == c.charCodeAt(0)) return true; } return false; } // getRealLengthFor // Parametri: // String s // Return int function getRealLengthFor(s,getDoubleChars) { if (isEmpty(s)) return 0; var chars = s.toCharArray(); var numberOfSpecialChars = 0; for (var k=0; k<chars.length; k++) { if (isIntInTheArray(chars[k], SPECIAL_CHARS)) { numberOfSpecialChars++; } } if(getDoubleChars === true) return numberOfSpecialChars; return s.length + numberOfSpecialChars; } // Conteggio SMS Basic - Mirko Mariani // Traduzione dall'algoritmo JAVA // Return Int // Parametri: // Integer len, String s function getNumberOfSegmentForBasic(len, s) { if (len <= 160) return 1; var leftStringToSplit = s; var segmentNumber = 0, cycle = 0, segmentLength = 0; var c = 'c'; var charForLeftString = null; while (!isEmpty(leftStringToSplit)) { var indexOfEndSegment = -1; var numberOfSpecialChars = 0; if ( cycle == 0 ) { segmentLength = 156; } else { segmentLength = 156; } // Check if we reached the last segment if ( getRealLengthFor( leftStringToSplit , false) > segmentLength ) { charForLeftString = leftStringToSplit.toCharArray(); for ( var k = 0; k < charForLeftString.length; k++ ) { if ( isIntInTheArray( charForLeftString[k], SPECIAL_CHARS ) ) { numberOfSpecialChars++; } } indexOfEndSegment = segmentLength - numberOfSpecialChars; // go to the point where cut the text var charChecked = 0; var charForCuttingFound = false; // search till the 15 char back while ( charChecked < 15 && !charForCuttingFound ) { c = leftStringToSplit.charAt( indexOfEndSegment - charChecked ); if ( isIntInTheArray( c, CHAR_TO_CUT_BASIC ) ) { segmentNumber++; charForCuttingFound = true; } else { charChecked++; } } // if no char has been found the string will be cut at the end of the segment length -> put the charChecked to 0 to // use the substring method below to determine the left string still to split if (!charForCuttingFound ) { segmentNumber++; charChecked = 0; } // change the left string still to split leftStringToSplit = leftStringToSplit.substring( indexOfEndSegment - charChecked, leftStringToSplit.length ); } else { // reset to end the cycle leftStringToSplit = ""; segmentNumber++; } cycle++; } return segmentNumber; } Validate.php <?php define("NET_ERROR", "Network+error+unable+to+send+the+message"); define("SENDER_ERROR", "You+can+specify+just+one+type+of+sender%2C+numeric+or+alphanumberic"); function do_post_request($url, $data, $optional_headers = null){ if(!function_exists('curl_init')) { $params = array( 'http' => array( 'method' => 'POST', 'content' => $data ) ); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { return 'status=failed&message='.NET_ERROR; } $response = @stream_get_contents($fp); if ($response === false) { return 'status=failed&message='.NET_ERROR; } return $response; } else { $ch = curl_init(); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_TIMEOUT,60); curl_setopt($ch,CURLOPT_USERAGENT,'Generic Client'); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); curl_setopt($ch,CURLOPT_URL,$url); if ($optional_headers !== null) { curl_setopt($ch,CURLOPT_HTTPHEADER,$optional_headers); } $response = curl_exec($ch); curl_close($ch); if(!$response){ return 'status=failed&message='.NET_ERROR; } return $response; } } function VMGatewaySendSMS($username,$password,$recipients,$text,$sms_type='basic',$sender_number='',$sender_string='',$charset='',$optional_headers=null) { $url = 'https://Myhostserver/WebsiteData/WebsiteDataEndpoint?wsdl'; switch($sms_type) { case 'classic': $method='send_sms_classic'; break; case 'report': $method='send_sms_classic_report'; break; case 'basic': default: $method='send_sms_basic'; } $parameters = 'method=' .urlencode($method).'&' .'username=' .urlencode($username).'&' .'password=' .urlencode($password).'&' .'text=' .urlencode($text).'&' .'recipients[]='.implode('&recipients[]=',$recipients) ; if($sender_number != '' && $sender_string != '') { parse_str('status=failed&message='.SENDER_ERROR,$result); return $result; } $parameters .= $sender_number != '' ? '&sender_number='.urlencode($sender_number) : ''; $parameters .= $sender_string != '' ? '&sender_string='.urlencode($sender_string) : ''; switch($charset) { case 'UTF-8': $parameters .= '&charset='.urlencode('UTF-8'); break; case '': case 'ISO-8859-1': default: } parse_str(do_post_request($url,$parameters,$optional_headers),$result); return $result; } ?>
  10. Anyone have any advice here for me please?
  11. Ok, well I eventually managed to find some thing that did the trick :-). Yes I am guild of the cardinal sin of copy and pasting code without actually fully understanding it. The problem I have not, and what I want to add to this code is: 1. Ignore the first line of the csv file (i.e. Headings) 2. On the success page, display the total line written to the database. The Code: (FORM) <html> <body> <form action="submit/submit_sales_upload.php" method="post" enctype="multipart/form-data"> <label for="file">Source File:</label> <input name="csv" type="file" id="csv" /> <input type="submit" name="submit" value="Upload File"> </form> </body> </html> (SUBMIT) <?php $con = mysql_connect("localhost","root","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydatabase", $con); if ($_FILES[csv][size] > 0) { if ($row == 1){ $row++; continue; } //get the csv file $file = $_FILES[csv][tmp_name]; $handle = fopen($file,"r"); //loop through the csv file and insert into database do { if ($data[0]) { mysql_query("INSERT INTO database.salesleads_ctr (champ ,msisdn ,alt_number ,id_number ,account_number ,sub_id ,customer_type ,campaign_code ,max_rrp_renew ,max_rrp_upgrade ,current_package ,cancellation_date) VALUES ( '".addslashes($data[0])."', '".addslashes($data[1])."', '".addslashes($data[2])."', '".addslashes($data[3])."', '".addslashes($data[4])."', '".addslashes($data[5])."', '".addslashes($data[6])."', '".addslashes($data[7])."', '".addslashes($data[8])."', '".addslashes($data[9])."', '".addslashes($data[10])."', '".addslashes($data[11])."' ) "); } } while ($data = fgetcsv($handle,1000,",","'")); // //redirect header('Location: redirect_import.php?success=1'); die; } ?>
  12. Hi All, I want to create a webpage that allows a user to import a csv file into a database. Can anyone help me start with this? Or at least refer me to a really good source that can help me get this working.
  13. Yea sorry, the underscore is because I have tested a few images with similar names just to get it working. It's weird though, the mail client doesn't recognise a second image being there i.e when you click on the option to download the images onyl the one image is downloaded. However when clicking the link to view it in your web browser, both images are visable. I'm gonna try your code now Muddy and see if that works.
  14. The images are both in the same location on the server. I have tried various images from this folder. the only difference is that the one image is a full background image for the entire page and the other image is an image embeded in a table. Here are the codes for the images: <body background='http://servername/img/mail_bg_main.jpg' alt='Background Image' width='100%' height='100%'><font face='Arial' size='2' color='white'> <table border='1' background='http://servername/img/mailbg.jpg' alt='Message Background Image' width='85%' align='center'><font face='Arial' size='2' color='white'> The image in the body tag works. The image in the table tag doesn't work.
  15. Ok cool, I now have the picture attaching etc. but, sadly only the first picture seems to attach. The second one doesn't. Also outlook is disabling the pictures from automatically displaying... Is there a way to force the pictures to display?
  16. Here is the code. Keep in mind that: A big part of this forms the actual body of the message. The server won't resolve as it is an internal server that I am testing on first. Some of the message body has been removed due to confidentiaity. Line 238 is the clsoing php tag -> ?> and will now be line 95 with the confidentiality part of the message body removed. <?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } if ( $_POST['owner'] == "Owner Name" ) { $to = "Owner@departmentname.co.za"; $from = 'csops@departmentname.co.za'; $subject = "New Request - Reference Number $_POST[reference]_$_POST[request_type]"; $message.= " <html> <body background='http://internalservername/img/mail_bg_main.jpg' alt='name/description of image' width='100%' height='100%'/><font face='Arial' size='2' color='black'> <table border='0' width='85%' background='http://internalservername/img/mail_bg.jpg' align='center'><font face='Arial' size='2' color='black'> <td> <table border='0' width='43%' align='center'> <td> <font face='Arial' size='2' color='black'>Hi $Name<br><br> Thank you for placing an online order with departmentname. Here is a summary of your order. Please keep this email as a reference if you wish to track your order.<br><br> Your order details are as follows:<br><br> <table border='' width='40%'><font face='Arial' size='2' color='black'> <tr> <td><strong><font face='Arial' size='2' color='black'>Order Number:</strong></td> <td></td> <td><font face='Arial' size='2' color='black'>.$orderNumber.</td> </tr> <tr> <td><strong><font face='Arial' size='2' color='black'>Order Date:</strong></td> <td></td> <td><font face='Arial' size='2' color='black'>.$orderDate.</td> </tr> </table><br><br> <table border='' width='100%'><font face='Arial' size='2' color='black'> <tr> <td width='25%'><font face='Arial' size='2' color='black'><strong>Deal Description</strong></td> <td width='25%'><font face='Arial' size='2' color='black'><strong>Quantity</strong></td> <td width='25%'><font face='Arial' size='2' color='black'><strong>Price</strong></td> <td width='25%' colspan='2'><font face='Arial' size='2' color='black'><strong>Amount</strong></td> </tr> <tr> <td width='25%'><font face='Arial' size='2' color='black'>$dealDescription</td> <td width='25%'><font face='Arial' size='2' color='black'>$quantity</td> <td width='25%'><font face='Arial' size='2' color='black'>$price</td> <td width='12.5%'><font face='Arial' size='2' color='black'>Total</td> <td width='12.5%'><font face='Arial' size='2' color='black'>$total</td> </tr> <table border='0' width='100%'><font face='Arial' size='2' color='black'> <tr> <td><font face='Arial' size='2' color='black'><strong>Returns Policy:</strong> You can cancel this order within two weeks after we have received it. You can return new, unopened items from a cancelled order within 2 weeks after they have been delivered to you. Items should be returned in their original packaging.<br> <br>Should you have any queries, do get in touch with our customer services team on: 0741 000 5555 or send us an email shoponline@departmentname.co.za<br> <br>Your new phone will be dispatched once all your details are confirmed.<br> <br>Look forward to welcoming you to the family!<br> <br>Best wishes,<br> <font color='CC0000'> departmentname South Africa</td> </tr> </table><br><br> </td> </table> </td> </table> </html>"; mail($to, $subject, $message, $from); ?>
  17. Now I get this error when hitting submit: Parse error: syntax error, unexpected end of file in \htdocs\submit\submit_drc_portal.php on line 238
  18. The url won't resolve as it is an internal server. The server isn't available externally. This mails will all be internal. Still can't get the picture to attach.
  19. My image isn't attaching :-\ $message.= "<body background='http://vmcedctr01/img/mail_bg_main.jpg' width='100%' height='100%'/><font face='Arial' size='2' color='black'>"; $message.= "Hi $_POST[owner]<br><br>"; $message.= "Thank you for placing an online order. Here is a summary of your order. Please keep this email as a reference if you wish to track your order.<br><br> Your order details are as follows:<br><br>"; $message.= "<table border=1 width='40%'>"; That's just the top part of the code.
  20. Yip, busy updating everything. Slowly working on it. Question though, can I have a CSS file in the script as well? Or do I have to format each part fot he message?
  21. Ok, thats how I had it, but I just realsied that I was being a bit of an idiot and I tried adding the image to the subject tag. And of coarse this won't display an image. So basic HTML/PHP coding from here on in. Thanks guys, I should be able to finifh this now.
  22. Cool thanks, I am going to work on this and then I will shout if I need more help . One thing that is not in there is what I would need to do if I wanted to add images into the mail.
  23. Hi All, Can anyone suggest where I can start looking to on how to create a HTL Rich E-Mail that is generated from a PHP form? I have done various searchs on Google and I haven't been able to find anything that seems to work. Basically, I want the form infor to be psoted to the MySQL database, but at the same time to send a HTML Rich E-mail to the used who completed the form. I have the normal e-mail and writing to the database working, I just want to spice it up now... Any help will be appreciated.
  24. That field forms part of a dynamic drop-down list. As depicted in the image. It is the first part of the dynamic drop-down, with two other dynamic drop-downs that are dependant on it.
×
×
  • 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.