Jump to content

siri

Members
  • Posts

    56
  • Joined

  • Last visited

Posts posted by siri

  1. I just did some Googling and found a simpler Reg Ex syntax:
    ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$

    Matches: joe@aol.com|||joe@wrox.co.uk|||joe@domain.infoNon-Matches: a@b|||notanemail|||joe@@.Try that :)

    It's not working .Can anyone tell me what's the mistake in my code
  2. he following code snippet always displays invalid.Here is the code snippet I used for email Validation:if(isset($_POST['submit'])){if(!eregi('^[a-zA-Z0-9-\_.]+@[a-zA-Z0-9-\_.]+\.[a-zA-Z0-9.]{2,5}$',$email)){$msg="Invalid";}else{$msg="Valid";}}Please let me know where exactly I am going wrong

  3. Hi,I tried the follwing code for uploading images but I am getting follwing error Warning: move_uploaded_file(/67ff50fd1e1519ec658b190ef4fd280a.jpg): failed to open stream: Read-only file system in on line 14Warning: move_uploaded_file(): Unable to move '/tmp/phpSXlIXr' to '/67ff50fd1e1519ec658b190ef4fd280a.jpg' in on line 14Here is the code:************************************<html><?php $path=$_SERVER[DOCUMENT_ROOT];if(isset($_post['submit'])){ $title=$_POST['title']; $thumb=$_POST['thumb']; $id=$_POST['alb']; $name= $_FILES['flimage']['name']; $ext=strchr($name,"."); $newname=md5(rand()*time()).$ext; $file=$path.$newname; $result = move_uploaded_file($_FILES['flimage']['tmp_name'], $file);if(!result){die('couldnot upload');}else{ echo 'Success';}if (!get_magic_quotes_gpc()) { $title = addslashes($title); $thumb = addslashes($thumb); $file=addslashes($file); } $conn=mysql_connect("db5.awardspace.com","pa","********");mysql_select_db("pa",$conn);$sql="insert into images(title,fname,alb_id,thumbnail) values('$title','$file',$id,'$thumb')";$result=mysql_query($sql);if(!result)die('Error');mysql_close($conn);}?><form action="" method=post enctype="multipart/form-data"><table border=1><tr><td>Title: </td><td><input type=text name=title></td></tr><tr><td>Thumbnail: </td><td><input type=text name=thumb></td></tr><tr><td>Album Id: </td><td><input type=text name=alb></td></tr><tr><td>File Name: </td><td><input type=file name=flimage></td></tr><tr><td><input type=submit name=submit value="Submit"></tr></table></form></body></html>

  4. Can anyone explain what exactly the serialize function does in the following code snippet:if (isset($_SESSION[products])) { 12: print "<b>Your cart:</b><ol>\n"; 13: foreach (unserialize($_SESSION[products]) as $p) { 14: print "<li>$p";

  5. I am having the following code to check if the radio button was selected or not*********************************************************************<html><head><script language="javascript">var ifunction check(){for(i=0;i<3;i++){if(document.frm.choice.checked){ return true;}else{ return false }} }</script></head><body><form name=frm method=post action="mailto:abc@xyz.com" onSubmit="return check()"><input type=radio name=choice value="Excellent">Excellent<br><input type=radio name=choice value="Good">Good<br><input type=radio name=choice value="Nothing special">Nothing Special<br><input type=submit name=submit value=submit></form></body></html>*****************************************But the code is not working.Where exactly is the mistake.

  6. I just want to know how I can clear the session variable after a specified time.I tried using the sleep function as follows:sleep(60);unset($_SESSION['members'];But it's not working.

  7. Friends,How to display the no of active users online and how to create a unique page views.I tried the following code:*********************************************************************<?phpsession_start();if(isset($_SESSION['views'])){$_SESSION['views']=$_SESSION['views']+1; if(isset($_COOKIE['visitors'])) { $_SESSION['views']=$_SESSION['VIEWS']-1; }}else{$_SESSION['views']=1;setcookie("visitors",1);}echo "Views: ".$_SESSION['views'];?>*************************************************************************Initially when I run this program it shows 1 but when I reload the page it displays as -1 .So how to create the unique page views.I tried to use cookies so that if the same visitor reloads the page then the session variable must be the same.So where exactly is the mistake.

  8. The program is working after using the phpmyadmin tool.I created the table named person and defined the follwing fields: firstnames lastname and age.and now my display.php is displaying the contents properly.But I am having one doubt regarding the php's built in functions for mysql.When I tried to create the table using php code (See main.php and insert.php code) it was giving me the error.But when i used the phpmyadmin it's working.So how to achieve the same functionality without using phpmyadmin

  9. Friends,I created the following php files : display.php*********************************<?php$con=mysql_connect("db5.awardspace.com","siri_online","********");if(!con){ die('could not connect' . mysql_error());}mysql_select_db("siri_online",$con);$result = mysql_query("select * from person");while($row = mysql_fetch_array($result)){ echo $row['firstname'] . " " . $row['lastname']; echo "<br/>";}mysql_close($con);?>****************************************insert.php file***************************************<?php$con=mysql_connect("db5.awardspace.com","siri_online","******");if(!con){ die('could not connect' . mysql_error());}mysql_select_db("siri_online",$con);mysql_query("insert into person(firstname,lastname,age)values('sami','gomes','21')");mysql_close($con);?>****************************************main.php file****************************************<?php$con=mysql_connect("db5.awardspace.com","siri_online","******");if(!con){ die('could not connect' . mysql_error());}mysql_select_db("siri_online",$con);$sql="create table person{ firstname varchar(12);lastname varchar(12);age int;}";mysql_query($sql,$con);mysql_close($con);?>******************************************but when i open the link http://myname.awardspace.com/display.php I am getting the following error :Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource inSo where exactly I am going wrong.

  10. Not quite sure, but i think it stops people injecting code and making the form send out loads of emails.PS. Is that the code from the Secure Email example here?
    I know but plz explain the syntax of this function and how it works in this case.
  11. Can anyone explain what exactly the function eregi("to:",$field) || eregi("cc:",$field) does in the following code:<?phpfunction spamcheck($field) {//eregi() performs a case insensitive regular expression match if(eregi("to:",$field) || eregi("cc:",$field)) { return TRUE; } else { return FALSE; } }//if "email" is filled out, send emailif (isset($_REQUEST['email'])) { //check if the email address is invalid $mailcheck = spamcheck($_REQUEST['email']); if ($mailcheck==TRUE) { echo "Invalid input"; } else { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("someone@example.com", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; } }else//if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; }?>

  12. I am looking for a free php hosting. But I am not getting the one.I agree there are lot of sites but i am not understanding how to use the mysql panel.So is they any good free hosting supporting php & Mysql which a newbie like me can use it with ease.

  13. Friends,I am a newbie as far as PHP & MYSQL is concerned. I have been told to do a project using PHP & MYSQL.So can anyyone of you suggest me a good project using PHP & MYSQL.The PHP tutorials of this site is really nice but I need some help as far as MYSQL is concerned.Thanks in advance.

×
×
  • Create New...