Jump to content

Amit20

Members
  • Posts

    71
  • Joined

  • Last visited

Everything posted by Amit20

  1. Hello everyone, I want to provide access to only those people to my website those who make entry into their hosts file. Can anyone explain me how to do this? Thank you!
  2. Great Look and feel. Design is superb Cheers!!!
  3. Hello again, Thank you everyone for your replies. I did tried modifying the code but alas, none seems to work. So what i did is, downloaded PHPMailer and tried using that too, but that too works on my localhost and a server that is in located in my country but not on the server on which i wanted to run the code. It is a remote server located in another country. I cannot make it out the cause of this. So can anyone tell the possible cause, maybe it will help me and others getting more knowledge about it. Cheers!!!
  4. Thank you very very very much DavidAM for your wonderful and generous reply. It allowed me to understand the things pretty clearly regarding emails. It was a good lesson to learn. Now the issue is only one thing, my code is working perfect on my localhost, but when i upload it on live server, it is not working; the email is shooted but i am not receiving it. I have checked the "From" email address; its valid since i am able to send it through a mailer. Also there's no error/warning returned by the mail function. Can you suggest what could be the probable cause for this behavior. Here's my working code, <?php error_reporting(E_ALL); define('UPLOAD_DIR',$_SERVER['DOCUMENT_ROOT'].'/support/php/uploads/'); //define('UPLOAD_DIR','C:\\xampp\\htdocs\\cyou\\uploads\\'); $allowed_extensions = array('jpeg','jpg','png','gif','pjpeg','bmp'); if($_FILES['file_upload']['name']) { $extension = explode('.',$_FILES['file_upload']['name']); if($_FILES['file_upload']['size'] <= 20971520 && in_array($extension[1],$allowed_extensions) ) { $file_name = $_FILES['file_upload']['name']; $file_size = $_FILES['file_upload']['size']; $file_type = $_FILES['file_upload']['type']; $file_temp_name = $_FILES['file_upload']['tmp_name']; if( file_exists($file_temp_name) ){ $isMoved = move_uploaded_file($file_temp_name,UPLOAD_DIR.$file_name); $isSent = sendMail('amit@gmail.com',$file_name,UPLOAD_DIR); if($isSent) echo "MAIL SENT \n"; else echo "MAIL NOT SENT"; } else echo "File does not exist"; } else echo " jpg,gif,bmp or png extensions are allowed. File size should not be more than 3 Mb"; } else { echo "NO FILE SELECTED"; } function sendMail($recepient_mail_id,$file_name,$path) { $file = $path.$file_name; $file_size = filesize($file); $handle = fopen($file,"r"); $content = fread($handle,$file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $to = $recepient_mail_id; $subject = "TEST EMAIL"; $from = "XYZ India"; $headers = 'From:support@abc.co.in'."\r\n".'X-Mailer: PHP/'."\r\n". phpversion(); $headers .= 'MIME-Version: 1.0'."\r\n"; $headers .= 'Content-Type: multipart/mixed; boundary=\"'.$uid."\"\r\n\r\n"; $message = 'This is a multi-part message in MIME format.'."\r\n"; $message.= "--".$uid."\r\n"; $message .= 'Content-type:text/html; charset=iso-8859-1'."\r\n"; $message .= 'Content-Transfer-Encoding: 7bit'."\r\n\r\n"; $message .= '<html><body>Dear Player, <br/> This is a Test Email !!!<br /> Team</body></html>'."\r\n"; $message .= "--".$uid."\r\n"; $message .= 'Content-Type: application/octet-stream;file='.$path.$file_name."; name=\"".$file_name."\"\r\n"; //$message .= "Content-Type: image/jpg; file=".$path.$file_name."\"\"\r\n"; $message .= 'Content-Transfer-Encoding: base64'."\r\n"; $message .= 'Content-Disposition: attachment;filename='.$file_name."\r\n\r\n"; $message .= $content."\r\n\r\n"; $message .= "--".$uid."--"; $isSuccess = false; if(mail($to,$subject,$message,$headers)) $isSuccess = true; else $isSuccess = false; return $isSuccess; } ?>
  5. Hello again, Thank you DavidAM, my problem is solved, and thank you jazzman1 i have made the appropriate changes suggested by you and yes your advice will be beneficial. Now i tested the code it works perfectly on localhost but when i tried it with the server on which the website is hosted its not working, like the mails are not being delivered. Also i am trying to send an image as an attachment which is not being attached on localhost as well. I have never sent attachment using php code, i am new to it. The attachment code i have referred from online tutorial. Here's m modified code <?php error_reporting(E_STRICT); define('UPLOAD_DIR',$_SERVER['DOCUMENT_ROOT'].'/support/php/uploads/'); //define('UPLOAD_DIR','C:\\xampp\\htdocs\\cyu\\uploads\\'); $allowed_extensions = array('jpeg','jpg','png','gif','pjpeg','bmp'); if($_FILES['file_upload']['name']) { $extension = explode('.',$_FILES['file_upload']['name']); if($_FILES['file_upload']['size'] <= 300000 && in_array($extension[1],$allowed_extensions) ) { $file_name = $_FILES['file_upload']['name']; $file_size = $_FILES['file_upload']['size']; $file_type = $_FILES['file_upload']['type']; $file_temp_name = $_FILES['file_upload']['tmp_name']; if( file_exists($file_temp_name) ){ $isMoved = move_uploaded_file($file_temp_name,UPLOAD_DIR.$file_name); $isSent = sendMail('amitg@gmail.com',$file_name,UPLOAD_DIR); if($isMoved) echo 'file transferred successfully'; else echo UPLOAD_DIR.$file_name; if($isSent) { echo "MAIL SENT \n"; } else echo "MAIL NOT SENT"; } else echo "File does not exist"; } else echo " jpg,gif,bmp or png extensions are allowed and file size should not be more than 3 Mb"; } else { echo "NO FILE SELECTED"; } function sendMail($recepient_mail_id,$file_name,$path) { $file = $path.$file_name; $file_size = filesize($file); $handle = fopen($file,"r"); $content = fread($handle,$file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $to = $recepient_mail_id; $subject = "TEST EMAIL"; $from = "XYZ India"; $headers .= 'MIME-Version: 1.0'."\r\n"; $headers .= 'From:support@abc.co.in'."\r\n".'X-Mailer: PHP/'."\r\n". phpversion(); $headers .= 'Content-Type: multipart/mixed; boundary=\"".$uid.\"\r\n\r\n'; $headers .= '--'.$uid.'\r\n'; $headers .= 'Content-Transfer-Encoding: 7bit\r\n\r\n'; $headers .= 'Content-Type: application/octet-stream; name = '.$file_name.'\r\n'; $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n"; $headers.= 'Content-Dispostion: attachment; file='.$file_name.'\r\n'; $headers .= $content.'\r\n\r\n'; $headers .= '--'.$uid.'--'; $headers .="Content-Type: image/jpg; file=".$file_name."\"\"\r\n"; $message = ' <html> <body> Dear Player,<br /><br /> This is TEST MAIL !!! Team India </body> </html>'; $isSuccess = false; if(mail($to,$subject,$message,$headers)) $isSuccess = true; else $isSuccess = false; return $isSuccess; } ?>
  6. Thank you PFMaBiSmAd for your quick reply. I added the headers to my code as suggested by you and also changed the directory path. You were right, images were uploaded to my document root directory. Now images are being uploaded correctly. But still mailis not being sent. Could there be any reason for this, since i am relying on hosting provider's mail settings and they are not in my control. So could you please tell me if there is something that i can test whether its working properly on my provider's side. Here's my modified code <?php define('UPLOAD_DIR',$_SERVER['DOCUMENT_ROOT'].'/support/php/uploads/'); if($_FILES['file_upload']['name']) { $file_name = $_FILES['file_upload']['name']; $file_size = $_FILES['file_upload']['size']; $file_type = $_FILES['file_upload']['type']; $file_temp_name = $_FILES['file_upload']['tmp_name']; $isMoved = move_uploaded_file($file_temp_name,UPLOAD_DIR.$file_name); $isSent = sendMail('abc@gmail.com',$file_name,UPLOAD_DIR); if($isMoved) echo 'File transferred successfully'; else echo 'File transmission failed'; if($isSent) { echo "MAIL SENT \n"; echo $file_name."\n"; echo $file_size."\n"; echo $file_temp_name."\n"; echo $file_type."\n"; } else echo "MAIL NOT SENT"; } else { echo "NO FILE SELECTED"; } function sendMail($recepient_mail_id,$file_name,$path) { $to = $recepient_mail_id; $subject = "Confirmation"; $from = "TEAM"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers = 'From: abc.co.in' . "\r\n". 'Reply-To: noreply@abc.co.in' . "\r\n" .'X-Mailer: PHP/' . phpversion(); $headers .= 'Content-type : text/html; charset=iso-8859-1' . "\r\n"; $message = ' <html> <body> Dear Player,<br /> Congratulations!!!<br /> Welcome !!!<br /> The test mail is successfully sent.<br /> </body> </html> '; $isSuccess = mail($to,$subject,$message,$headers); return $isSuccess; } ?>
  7. Hello everyone, I am facing some unexpected problem. I have a php script that is used to send email to the recepient. My script is running fine no error occurs while executing it. The problem is, the mail is sent (mail() function returns true), but the mail is not received. Also the move_uploaded_file() functions return true but when i check the directory there is no image in it. Here's my code <?php define('UPLOAD_DIR',$_SERVER['DOCUMENT_ROOT'].'/uploads'); if($_FILES['file_upload']['name']) { $file_name = $_FILES['file_upload']['name']; $file_size = $_FILES['file_upload']['size']; $file_type = $_FILES['file_upload']['type']; $file_temp_name = $_FILES['file_upload']['tmp_name']; if( file_exists($file_temp_name) ){ $isMoved = move_uploaded_file($file_temp_name,UPLOAD_DIR.$file_name); $isSent = sendMail('recipient_id@mail.com',$file_name,UPLOAD_DIR); if($isSent && $isMoved) { echo "MAIL SENT \n"; echo $file_name."\n"; echo $file_size."\n"; echo $file_temp_name."\n"; echo $file_type."\n"; } else echo "MAIL NOT SENT SINCE IMAGE FILE WAS NOT UPLOADED"; } else { echo "NO FILE SELECTED"; } function sendMail($recepient_mail_id,$file_name,$path) { $to = $recepient_mail_id; $subject = "Confirmation"; $from = "TEAM"; $message = ' <html> <body> Dear Player,<br /> <br /> Congratulations!!!<br /> <br /> <span style="background-color:#F00; color:#FFF; padding:5px; font-weight:bold; font-size:18px;"></span><br /><br /> Welcom!!!<br /> <br /> The test mail is successfully sent. <br /> </body> </html> '; $isSuccess = mail($to,$subject,$message,$headers); return $isSuccess; } ?> ANy help will be highly appreciated!
  8. Thanks a ton for your reply. I have not yet started but need to know if its possible. Because most of the part of my site is static and i want to make some sections in CMS so that can be updated easily. How will i able to do that??? I have knowledge about Wordpress..
  9. Hello everyone!!!! I have a website which has some section like news, events. Now my entire site is not developed using CMS. Its just HTML, JS,CSS. But now i want to make the above sections in CMS. Is it possible??? Any reply will be appreciated!
  10. What you are doing thats absolutely correct. But i suggest you follow this link. http://www.javascriptkit.com/javatutors/eventaction.shtml Hope it helps!!!
  11. Use 'target' attribute of anchor tag. <a href="#" target="_blank"
  12. First try with passing any color rather than using image! If that's working then u need to debug your code using web console or firebug!
  13. Check out this code. It'll Help! function getCookie(cookieName){ if(document.cookie.length>0){ var begin = document.cookie.indexOf(cookieName+"="); if(begin!=-1){ begin += cookieName.length+1; var end = document.cookie.indexOf(";", begin); if (end == -1){ end = document.cookie.length; } return unescape(document.cookie.substring(begin,end)); } return null; } }
  14. Hello Everyone, Now this is the issue which i m not understanding at all. I m creating a cookie with folowing code function setCookie(name,value){ var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (1 * 24 * 3600 * 1000)); document.cookie = name+"="+value+";expires="+ExpireDate.toGMTString()+"; path=/"; } . The point is cookie is being created but it does not show the expiry date, when i call document.cookie in firebug it gives me following output "JSESSIONID=C5A6A2C72DC227F44D332B6FF194356F; Institute=4; Stream=3; Course=12". But when i change the semi-colon with exclaimation mark in this sentence before the word "Expires" as this then it gives me this output "JSESSIONID=C5A6A2C72DC227F44D332B6FF194356F; Institute=5!expires=Tue, 08 Nov 2011 09:38:55 GMT; Stream=5!expires=Tue, 08 Nov 2011 09:38:56 GMT; Course=3!expires=Tue, 08 Nov 2011 09:38:57 GMT" . Can anyone please explain this behaviour!!! Any help will be highly appreciated
  15. Thank you mjdamato. I'll try the code and check it out.
  16. Hello Friends! A simple code. Please anyone tell me what is wrong with this piece of code... When i call this function it does not clear the cookie!!! function deleteCookie(cookieName){ if(document.cookie.length>0){ document.cookie = cookieName + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } Any help will be highly appreciated!
  17. Which server are you using? By default, whichever server it is, when u call your domain it will search for index.html, index.htm, index.php or login.php. But since you say that when u change it to index.php your file is not fetched then you may have to check your server configuration.
  18. Thank You very much Ok i will build a query through loop. Thank you once again for your help
  19. Thank you for your reply Firstly, i do have an Auto-increment value, i wont be inserting it manually. Secondly, I like your idea of using multiple inserts but what if i have say around 50 entries at a time.. Is my previous code reliable???
  20. Hello Friends i just need your reviews for the following code <?php session_start(); require_once("conf.php"); mysql_select_db('site'); $subjects=$_GET['sublen']; $username=$_SESSION['user']; for($i=1;$i<=$subjects;$i++) { $subject=$_GET[',Sub'.$i]; $query="INSERT INTO Subjects(id,Subjects,User,Classs) VALUES($i,'$subject','$username','F.Y.B.Sc')"; $true=mysql_query($query) or die("Cannot Store subjects".mysql_error()); } ?> Is this a valid way to store data in database????
  21. Hope this code explains you how you can fit your events in their td's while($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; echo $row['Event1']; echo "</td>"; echo "<td>"; echo $row['Event2']; echo "</td>"; echo "</tr>"; }
  22. Databases are designed to handle large amount of data. So need not worry about the size of data.. If size of your data increases still your database will handle it, just take care that you have a normalized table so your database responds efficiently. Also when data increases, your RAM and processor must be well capable on your local machine.
  23. Thank You codeprada for your reply. As i said in my last reply that the data i m sending is a JS array. Here is the code, <script type="text/javascript"> function getNoOfSub() { var subj=document.getElementById('subjects').value; return subj; } function getSubjects() { var totalSubjects=getNoOfSub(); var subjectArray = new Array(); for(var i=1;i<=totalSubjects;i++) { var s=document.getElementById('subject'+i).value; subjectArray.push("Sub"+i+"="+s+"&"); } window.location="storeSubjects.php?&,"+subjectArray+"&sublen="+subjectArray.length; } </script> So any suggestions how can i manage this????
  24. Thank you Xpluration for your reply, but the thing is i m not sending form data, instead; i m sending a javascript array. And i guess i can't send a JS array through post because that array is created by JS function.
  25. Hello Everyone, I m making an attendance application. I have an issue with following code, <?php session_start(); require_once("conf.php"); mysql_select_db('site'); $subjects=$_GET['sublen']; $username=$_SESSION['user']; for($i=1;$i<=$subjects;$i++) { $subject=$_GET[',Sub'.$i]; $query="INSERT INTO Subjects(id,Subjects,User,Classs) VALUES($i,'$subject','$username','F.Y.B.Sc')"; $true=mysql_query($query) or die("Cannot Store subjects".mysql_error()); } ?> <html> <head> <link href="../css/style.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../js/jquery.js"></script> </head> <body> <div id="main"> <div id="logo"> KiMi... </div> <div id="header"> <ul> <li><a href="index.html">Home</a></li> <li><a href="php/subjectsTable.php">Create Subjects</a></li> <li><a href="html/form.html">Contact Us</a></li> <li><a href="html/register.php">Register!</a></li> </ul> </div> <div id="nav"> </div> <div id="content"> <?php if($true) { echo "<div id='dynamicDiv'>"; echo "<div> Subjects stored Successfully!</div></br></br>"; $query="SELECT * FROM Subjects Where User='$username'"; $result=mysql_query($query) or die("Cannot Fetch Data"); echo "<table id='table'>"; echo "<tr><td> </td><td>Subjects</td><td>Class</td></tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td><input type='checkbox' name='box[]'/> </td>"; echo "<td>"; echo $row['Subjects']; echo "</td>"; echo "<td>"; echo $row['Classs']; echo "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; } ?> </div> <div id="footer"> &#169; Copyright Amit K. Goda 2011-2012 </div> </div> </body> </html> In the above code i m storing data into database which has been passed into $_GET array. The Code is this the data is stored but the issue is, since i have data coming in $_GET array when i reload my page the same data is stored again inmy database. So any suggesstions how can i avoid that??? Any Help will be highly appreciated
×
×
  • 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.