Jump to content

nosmas

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nosmas's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. But I didn't use any statement that displays any thing AND I posted those two error reporting lines you provided me but it is still the same
  2. hello friends I was working on a login form and I used header() function for working, but it ain't redirecting.It is just showing an empty(white) page. _____________________________________________ here is the php code _______________________________________________ <?php //login.php include('includes/db.php'); include('includes/session.php'); $user_id=$_POST['user_id']; $password=md5($_POST['password']);//crypt the password b/c the pwd in db is crypted $query1="SELECT *FROM user WHERE user_id='$user_id' AND user_password='$password'"; $result1=mysql_query($query1) or die(mysql_error()); if(mysql_num_rows($result1)>0){//check if the user exists in the user table setUserSession($user_id,$password); header("Location:user.php?SID"); exit(0); }else{ $query2="SELECT *FROM admin WHERE user_id='$user_id' AND password='$password'"; $result2=mysql_query($query2) or die(mysql_error()); die(mysql_num_rows($result2)); if(mysql_num_rows($result2)>0){//check if the user exists in the admin table setAdminSession($user_id,$password); header("Location:admin.php?SID"); exit(0); }else{ $msg="wrong username or password"; header("Location:login1.php?msg=$msg"); exit(0); } } ?> __________________________________________________ here is the login form ___________________________________________________ <? if(isset($_GET['msg']) && !empty($_GET['msg'])){ echo "<font color=\"red\" >$msg</fornt>"; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <form action="login.php" method="post"> <pre> <fieldset> user ID<input type="text" name="user_id" maxlength="10" /><br /> Password<input type="password" name="password" maxlength="12" /><br /> <input type="submit" value="login" /> </fieldset> </pre> </form> </body> </html>
  3. I was just building a page that enables the admin to upload news with multiple images,But i do not know how to replace the images while editing the news. here is the code that uploads the news <?php if(!isset($_POST['multipic'])){ filter_file($_FILES['picture']['type'],$_FILES['picture']['size']); if($_FILES['picture']['error']){ $msg="the picture".$_FILES['picture']['name']."has got an error"; header("Location:uploadNews.php?msg=$msg"); exit(0); } $title=strip_tags($_POST['title']); $detail=strip_tags($_POST['detail']); $author=strip_tags($_POST['author']); $query2="INSERT INTO news(title,detail,author) VALUES('$title','$detail','$author')"; mysql_query($query2)or die(mysql_error()."lilne-30"); $news_id=mysql_insert_id(); $path="upload/news".$news_id.$_FILES['picture']['name']; $name=$_FILES['picture']['name']; move_uploaded_file($_FILES['picture']['tmp_name'],$path ); $query1="INSERT INTO picture(pic_path,pic_caption) VALUES('$path','$name') "; mysql_query($query1) or die(mysql_error()."line-24"); $pic_id=mysql_insert_id(); $query3="INSERT INTO news_picture VALUES($news_id,$pic_id)"; mysql_query($query3) or die(mysql_error()."line-33"); if(isset($_POST['add_pic']) && !empty($_POST['add_pic'])&&($_POST['add_pic']!="0")){ ?> <form action="<?echo $_SERVER[php_SELF]?>" method="post" enctype="multipart/form-data"> <input type="hidden" value="<?echo $_POST['title']?>" name="title" /><br /> <input type="hidden" value="<?echo $_POST['detail']?>" name="detail" /><br /> <input type="hidden" value="<?echo $_POST['add_pic']?>" name="num_pic" /><br /> <input type="hidden" value="<?echo $news_id?>" name="news_id" /><br /> <input type="hidden" value="1" name="multipic" /> <? for($i=0;$i<$_POST['add_pic'];$i++){ $name="pic".$i; echo "picture".$i+1; ?> <input type="file" name="<?echo $name?>" /><br /> <? } ?> <input type="submit" value="Upload" /> </form> <? }else{ die (":-) done"); } }else{ $news_id=$_POST['news_id']; for($i=0;$i<$_POST['num_pic'];$i++){ $name='pic'.$i; filter_file($_FILES[$name]['type'],$_FILES[$name]['size']); if($_FILES[$name]['error']){ $msg="the picture".$_FILES[$name]['name']."has got an error"; header("Location:uploadNews.php?msg=$msg"); exit(0); } $path="upload/".$news_id.$i.$_FILES[$name]['name']; move_uploaded_file($_FILES[$name]['tmp_name'],$path ); $query1="INSERT INTO picture(pic_path,pic_caption) VALUES('$path','$name') "; mysql_query($query1) or die(mysql_error()."line-82"); $pic_id=mysql_insert_id(); $query2="INSERT INTO news_picture VALUES($news_id,$pic_id)"; mysql_query($query2) or die(mysql_error()."line-86"); }die(":-)donnne"); } ?>
  4. hello friends! can any body show me how to replace an uploaded file
  5. Hi guys. I was working with a page that includes uploading pictures. I uploaded the image File and saved the path in mysql database, but I didn't feel this is safe.Can any body show me how to upload an image directly into mysql database. thanks for your help.
×
×
  • 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.