Jump to content

raghu_tak

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by raghu_tak

  1. i have an array i want every element to be echoed but they should be echoed one by one with the gap of 3 second b/w them.
  2. Hello friends can anyone help me how to access array elements with some specific time. like if an array is defined $a with 3 elements in it. then o/p should be like that every element is echoed once for some second.then next element and then last. i am learning php so please help in php coding only. Thanks a lot Awaiting for your positive response.
  3. Hi friends I am trying to align a picture grabbed from database in right side within fieldset. but this is not working please help me in it friends. echo'<fieldset style="width:400;align=center;"><legend>Your Profile</legend>'; echo'<table>'; echo'<tr><td>Name: '.$row['firstname'].' '.$row['lastname'].'</td>'; if(!empty($row['picture'])) { echo'<td><img src=" '.upath.$pic.' " alt="Image not found" width="80" height="80" align="middle"></td></tr><br/>'; } else { echo'<td><img src="images1/nopic.jpg" alt="Image not found" width="80" height="80" align="middle"></td></tr><br/>'; }
  4. But following script causing another problem you see i get following errors Warning: move_uploaded_file() [function.move-uploaded-file]: The second argument to copy() function cannot be a directory in C:\xampp\htdocs\raghu\mismatch\edit.php on line 26 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\php121B.tmp' to 'images1/' in C:\xampp\htdocs\raghu\mismatch\edit.php on line 26 if(move_uploaded_file($_FILES['screenshot']['tmp_name'],$target)) { $query="SELECT * FROM mismatch_user WHERE user_id=$id1"; $result=mysqli_query($dbc,$query) or die('Error getting data'); if(mysqli_num_rows($result)==1) { $query1="UPDATE mismatch_user SET firstname='$fname', lastname='$lname', birthday='$bday',". "gender='$sex', country='$nation', picture='$screenshot' WHERE user_id='$id1'"; $result1=mysqli_query($dbc,$query1) or die('Error quering database'); echo'<br/><b>Profile Edited successfully</b>';
  5. hey thanks a lot it now updated i retried again and now this worked but i don't know what happened to it first time..lol Thanks a lot genius.
  6. i wrote this this session_start() in my script but nothing happened same output nothing. but when i write if(!isset($_SESSION['user_id'])) at place of if(isset($_SESSION['user_id'])) i got feedback 'profile updated successfully'. but when i saw my database nothing was updated.
  7. yes i have built a login system that redirects to edit page means current page but when we edit our information no data is updated in database and i have created a session using session_start(); so i didnt use it again in edit page because session_id is set now. i am attaching login script too please have a look on it too. loginx.php
  8. nothing is displayed just NULL is written on top left corner... why?
  9. Sorry but please explain what will var_dump will do and what it is?
  10. even this code not executed echo 'Form is submitted<br>';
  11. this is a file please see it once this code is get refreshed everytime when i click a submit button. edit.php
  12. friend i have did all this stuff but its not helping me
  13. friends,this is a code of head first php book it is used to edit a profile of user who has logged in but when i edit a profile the page displayed again with no feedback please help me friends!! <html> <head><title> Edit Profile </title></head> <body> <h1 style="color:brown;"><center>Please Edit your profile to find new mismatch.</center></h1> <form enctype="multipart/form-data" method="post" action="<?php echo$_SERVER['PHP_SELF']; ?>"> <p><i><center>This information would be seen by others and easily get connected to you.</center></i></p> <hr/> <img src="images1\mismatch.jpg" width="400" height="400" alt="mismatch image." align="right"> <fieldset style="width:250"> <legend>Edit your profile</legend> <table><tr> <td><label for="fname">Firstname:</label></td> <td><input type="text" id="fname" name="fname"><br/></td> </tr><tr> <td><label for="lname">Lastname:</label></td> <td><input type="text" id="lname" name="lname"><br/></td> </tr><tr> <td><label for="bday">Birthday:</label></td> <td><input type="text" id="bday" name="bday"><br/></td> </tr><tr> <td><label for="sex">Gender:</label></td> <td><input type="text" id="sex" name="sex"><br/></td> </tr><tr> <td><label for="nation">Country:</label></td> <td><input type="text" id="nation" name="nation"><br/></td> </tr><tr> <td><label for="screenshot">Picture:</label></td> <td><input type="file" name="screenshot" value="Choose image"><br/></td> </tr></table> </fieldset> <input type="submit" name="submit" value="Save"> <?php define('upath','mismatch/images1/'); define('msize',1024*50); if(isset($_SESSION['user_id'])) { $id1=$_SESSION['user_id']; if(isset($_POST['submit'])) { $dbc=mysqli_connect('localhost','root','','mismatch') or die('Error connceting database'); if((!empty($_POST['fname']))&&(!empty($_POST['lname']))&&(!empty($_POST['bday']))&& (!empty($_POST['sex']))&&(!empty($_POST['nation']))) { $fname=$_POST['fname']; $lname=$_POST['lname']; $bday=$_POST['bday']; $sex=$_POST['sex']; $nation=$_POST['nation']; if(!empty($_FILES['screenshot']['name'])) { $screenshot=$_FILES['screenshot']['name']; if(($_FILES['screenshot']['size']>0)&&($_FILES['screenshot']['size']<msize)) { $target=upath.$screesnhot; if(move_uploaded_file($_FILES['screenshot']['tmp_name'],$target)) { $query="SELECT * FROM mismatch_user WHERE user_id=$id1"; $result=mysqli_query($dbc,$query) or die('Error getting data'); if(mysqli_num_rows($result)==1) { $query1="UPDATE mismatch_user SET firstname='$fname', lastname='$lname', birthday='$bday',". "gender='$sex', country='$nation', picture='$screenshot' WHERE user_id='$id1'"; $result1=mysqli_query($dbc,$query1) or die('Error quering database'); echo'<br/><b>Profile Edited successfully</b>'; } } else { echo'<br/><b/>File cannot be uploaded'; } } else { echo'<br/><b/>Check size of Image.'; } } else { $query1="UPDATE mismatch_user SET firstname='$fname', lastname='$lname', birthday='$bday',". "gender='$sex', country='$nation' WHERE user_id='$id1'"; $result2=mysqli_query($dbc,$query2) or die('Error quering database'); echo'<br/><b>Profile Edited successfully</b>'; } } else { echo'<br/><b/>Please Enter all the information.'; } } } ?> </body></html>
  14. hi friends i am learning php from head first php book i have written a login script code from book that is similar to it but when i submit the user info it display again this login script. but when i run this book's code it works fine. the both script are similar. the following is my code and next to it is book's. My code:- <?php session_start(); $errormsg=""; if(!isset($_SESSION['user_id'])) { if(isset($_POST['submit'])) { $dbc=mysqli_connect('localhost','root','','mismatch') or die('Error connecting database'); $uname=mysqli_real_escape_string($dbc,trim($_POST['user_name'])); $pword=mysqli_real_escape_string($dbc,trim($_POST['pass_word'])); if((!empty($uname))&&(!empty($pword))) { $query="SELECT * FROM 'mismatch'.'mismatch_user' WHERE username='$uname' AND password=SHA('$pword')"; $result=mysqli_query($dbc,$query) or die('Error quering database'); if(mysqli_num_rows($result) == 1) { $row=mysqli_fetch_array($result); $_SESSION['user_id']=$row['user_id']; $_SESSION['username']=$row['username']; echo'You have successfully logged in as '.$_SESSION['username'].'.<br/>'; echo'<a href=edit.php>Edit your profile</a>'; mysqli_close($dbc); } else { $errormsg='Sorry try different user name.'; } } else { $errormsg='Please enter all the information to log in.'; } } } ?> <html> <head><title> Log in </title></head> <body> <h1 style="color:Darkcyan"><center>Welcome to Mismatch.com</center></h1> <p><center><i>Please enter your log in info to access your page.</i></center></p> <?php if(empty($_SESSION['user_id'])) { echo $errormsg; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Log in</legend> <label for="user_name">Username:</label> <input type="text" name="user_name" value="<?php if(!empty($uname)) echo $uname; ?>"/> <label for="pass_word">Password:</label> <input type="password" name="pass_word"/> </fieldset> <input type="submit" name="login" value="Log in"> </form> <?php } ?> </body></html> and here is book's code <?php // Start the session session_start(); // Clear the error message $error_msg = ""; // If the user isn't logged in, try to log them in if (!isset($_SESSION['user_id'])) { if (isset($_POST['submit'])) { // Connect to the database $dbc = mysqli_connect('localhost','root','','mismatch'); // Grab the user-entered log-in data $user_username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_password = mysqli_real_escape_string($dbc, trim($_POST['password'])); if (!empty($user_username) && !empty($user_password)) { // Look up the username and password in the database $query = "SELECT user_id, username FROM mismatch_user WHERE username = '$user_username' AND password = SHA('$user_password')"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The log-in is OK so set the user ID and username session vars (and cookies), and redirect to the home page $row = mysqli_fetch_array($data); $_SESSION['user_id'] = $row['user_id']; $_SESSION['username'] = $row['username']; echo'you have successfully logged in as '.$_SESSION['username'].'.<br/>'; echo'<a href=edit.php>Edit your profile</a>'; } else { // The username/password are incorrect so set an error message $error_msg = 'Sorry, you must enter a valid username and password to log in.'; } } else { // The username/password weren't entered so set an error message $error_msg = 'Sorry, you must enter your username and password to log in.'; } } } ?> <html> <head> <title>Mismatch - Log In</title> </head> <body> <h3>Mismatch - Log In</h3> <?php // If the session var is empty, show any error message and the log-in form; otherwise confirm the log-in if (empty($_SESSION['user_id'])) { echo $error_msg; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Log In</legend> <label for="username">Username:</label> <input type="text" name="username" value="<?php if (!empty($user_username)) echo $user_username; ?>" /><br /> <label for="password">Password:</label> <input type="password" name="password" /> </fieldset> <input type="submit" value="Log In" name="submit" /> </form> <?php } ?> </body> </html> please help me friends!!
×
×
  • 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.