
mdvignesh
Members-
Posts
60 -
Joined
-
Last visited
Everything posted by mdvignesh
-
change link text <?php require 'connect.php'; ?> <html> <head><title>Admin</title> <link rel="stylesheet" type="text/css" href="tab_style.css"> <script type="text/javascript"> function getXMLHTTP() { var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function approve(e) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById("appr <?php echo $fet['s_id']; ?>").innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", "approve.php?stu="+e, true); req.send(null); } } function block(b) { var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('blok').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", "block.php?blo="+b, true); req.send(null); } } </script> </head> <body> <?php $admin_err=''; $pass_err=''; if (isset ($_REQUEST['submit'])) { require 'connect.php'; $admin = $_REQUEST['admin']; $pass = $_REQUEST['password']; $err=0; if($admin=="") { $admin_err="enter username"; $err=1; } if($pass=="") { $pass_err="enter password"; $err=1; } if ($err == 0) { $check = mysql_query("SELECT admin FROM admin_login WHERE admin='".$admin."' and password='".$pass."' "); $exi = mysql_num_rows ($check); if($exi == 0) $err_msg = "Username/password combination incorrect."; else { $sel = mysql_query("SELECT * FROM stud"); echo "<h4 class='table-caption'>Students</h4>"; while ($fet = mysql_fetch_array($sel)) { ?> <div class="base-layer"> <div class="table-row"> <div class="c_one"><p class="text"> <? echo $fet['name']; ?></p></div> <div class="c_two"><p class="text"> <? echo $fet['email']; ?></p></div> <div class="c_three"><p class="text"> <? echo $fet['school']; ?></p></div> <div class="c_four"><p class="text"> <? echo $fet['subject']; ?></p></div> <div class="c_five"><p class="text"> <? echo $fet['class']; ?></p></div> <div class="c_six"><p class="text"> <? echo $fet['teacher']; ?></p></div> <div class="c_seven" id="appr <?php echo $fet['s_id']; ?>"><p class="text"> <?php if ($fet['approve'] == 0) ?> <a href="#" onClick="return approve(<?php echo $fet['s_id']; ?>);" style="text-decoration:none"> Approve</a> </p> </div> <div class="c_eight" id="block"><p class="text"> <?php if($fet['approve'] == 1) ?> <a href="#" onClick="block(<?php echo $fet['s_id']; ?>);" style="text-decoration:none"> Block </a> </p> </div> <div class="space-line"> </div> </div> </div> <?php } die(mysql_error()); } } } ?> <form id="formid" method="post" name="myform" action=""> <p> <label for="username">Admin:</label> <input name="admin" type="text" size="20" value="<?php if(isset($admin)) echo $admin; ?>" /> <?php echo $admin_err; ?> </p> <p> <label for="pass">Password:</label> <input name="password" type="password" value="<?php if(isset($pass)) echo $pass;?>" /> <?php echo $pass_err; ?> </p> <p> <input name="submit" type="submit" value="Log in" > </p> <?php if(isset($err_msg)) echo $err_msg; ?> </form> </body> </html> approve.php <?php require_once 'connect.php'; $id = $_REQUEST['stu']; $upd = mysql_query ("UPDATE stud SET approve = '1' WHERE s_id = ".$id." "); if (!$upd) die(mysql_error()); //header("Location:administrator.php"); echo "Approved"; //echo "<h3>Student Approved</h3>"; ?>
-
<?php function generateThumbs() { $pathToScreens = "D:/wamp/www/vignesh_2/up_images/"; // Directory to your images you want converted to thumbnails. $pathToThumbs = "D:/wamp/www/vignesh_2/up_images/thumb/"; // Directory to your thumbnails. $thumbWidth = 70; // Width of the thumbnails generated. $dir = opendir($pathToScreens) or die("Could not open directory"); $counter = 0; while(($fname = readdir($dir)) !== false) { if($fname != "." && $fname != "..") { // Remove folders. $valid_extensions = array("jpg","jpeg","gif","png"); // Only jpeg images allowed. $info = pathinfo($pathToScreens . $fname); // print_r($info); if( in_array (strtolower ($info["extension"]),$valid_extensions)) { // Make sure the file is an image file by checking its extension to the array of image extensions. $img = imagecreatefromjpeg($pathToScreens . $fname); // Select the file as an image from the directory. $width = imagesx($img); $height = imagesy($img); // Collect its width and height. $newHeight = floor($height * ($thumbWidth / $width)); // Calculate new height for thumbnail. $tempImage = imagecreatetruecolor($thumbWidth,$newHeight); // Create a temporary image of the thumbnail. // Copy and resize old image into new image. imagecopyresized($tempImage,$img, 0, 0, 0, 0, $thumbWidth,$newHeight,$width,$height); $genThumb = imagejpeg($tempImage,$pathToThumbs . $fname); // Create the thumbnail with the new width and height in the thumbnails directory. // I added a rand 3 digit number in front of the file name to avoid overwrite. $counter++; // Increment. } } } if($counter > 0) { return $counter . " thumbnails generated from the directory \"".$pathToScreens."\"."; } else { return "No image files could be processed."; } closedir($dir); // Close the directory. } //echo "<img src='up_images/thumb/650Blue hills.jpg' />"; ?> 17526_.php
-
Help me I am getting Notice: Undefined index: extension
-
thank u very much but how to overwrite
-
Help me. What I am doing is editing a form with checkboxes... and updating image .. I uploaded scripts I want to delete old jpeg file from thumb folder and update new filename in db <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> function show_confirm() { var r=confirm("Delete?"); if (r==true) { //javascript:window.location='view.php'; alert("Deleted!!"); } else { //javascript:window.location='view.php'; alert("You pressed Cancel!"); return false; } } </script> </head> <body> <?php require("connect.php"); if ($_REQUEST['submit']) { $id=$_POST['hide']; for($i=1; $i<=$id; $i++) { $query2 = mysql_query("SELECT * from stu_detail WHERE id = $id "); while($file = mysql_fetch_array($query2)) { $unlink = unlink("up_images/thumb/" . $file['filename']); } } $new_name=$_POST['name']; $new_email=$_POST['email']; $new_phone=$_POST['phone']; $new_gender=$_POST['rad']; $new_city=$_POST['city']; $new_lang=implode(",",$_POST['chk']); $tar = "c:/wamp/www/rms/vignesh_2/up_images/"; if ($_FILES['efile']['error'] > 0) echo "Error" . $_FILES["efile"]["error"]; else { if (file_exists ("$tar" . $_FILES['efile']['name'])) { echo $_FILES['efile']['name'] . " already exsists"; } else { move_uploaded_file ($_FILES['efile']['tmp_name'],"$tar" . $_FILES['efile']['name']); } } $qry=mysql_query("UPDATE stu_detail SET name='".$new_name."', email='".$new_email."', phone='".$new_phone."', gender='".$new_gender."', city='".$new_city."', lang='".$new_lang."', filename='".$_FILES['efile']['name']."' WHERE id=$id ") or die(mysql_error()); require_once("create_thumb.php"); echo generateThumbs(); if (!$qry) { echo "not updated"; } else { echo "<table align='center' border='1' width='800' height='600'>"; ?><tr> <th scope="col">Name</th> <th scope="col">E-mail Address</th> <th scope="col">Phone</th> <th scope="col">Gender</th> <th scope="col">City</th> <th scope="col">Language</th> </tr> <?php $recyc=mysql_query("SELECT * FROM stu_detail where status = 1") or die(mysql_error()); $del = mysql_num_rows($recyc); if ($del != 0) echo "<a href='recycled.php'>Recycle bin</a>"; if ($qry2=mysql_query("SELECT * FROM stu_detail where status = 0 order by id desc") ) { while($res=mysql_fetch_array($qry2)) { ?> <tr> <td><?php echo $res['name']; ?></td> <td><?php echo $res['email']; ?></td> <td><?php echo $res['phone']; ?></td> <td><?php echo $res['gender']; ?></td> <td><?php echo $res['city']; ?></td> <td><?php echo $res['lang']; ?></td> <td> <img src="up_images/thumb/<?php echo $res['filename']; ?>" /> </td> <td> <a href="edit.php?uid=<?php echo $res['id']; ?>">edit</a></td> <!--<td><button type="button" onClick="return show_confirm();">Delete</button> </td>--> <td> <a href="delete.php?uid=<?php echo $res['id']; ?>" onClick="return show_confirm();">delete</a></td> </tr> <?php } } ?> </table> <?php } } ?> </body> </html> 17500_.php 17501_.php
-
Not able to validate checkbox If no checkbox is selected I need alert message
-
Checkbox value has to inserted into database Also I have JavaScript check box validation I don't know what to give name for checkbox register.php <html> <head> <script type="text/javascript"> function regval() { //name validation var name_val=document.registration.uname.value; if(name_val=="") { alert("enter first name"); document.registration.uname.focus(); return false; } else if(name_val!='') { var name_re =/^[-A-Za-z. ]*$/; if(name_re.test(name_val) == false) { alert("enter valid name"); document.registration.uname.focus(); return false; } } //email validation var mail_val=document.registration.email1.value; if(mail_val=="") { alert("enter email address"); document.registration.email1.focus(); return false; } else if(mail_val!="") { var mailcheck = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if(mailcheck.test(mail_val)==false) { alert("enter valid email address"); document.registration.email1.focus(); return false; } } //city validation var city_val=document.registration.ucity.value; if(city_val=="") { alert("enter city name"); document.registration.ucity.focus(); return false; } else if(city_val!='') { var city_re =/^[-A-Za-z. ]*$/; if(city_re.test(city_val) == false) { alert("enter valid city name"); document.registration.ucity.focus(); return false; } } //state validation var state_val=document.registration.ustate.value; if(state_val=="") { alert("enter state name"); document.registration.ustate.focus(); return false; } else if(state_val!='') { var state_re =/^[-A-Za-z. ]*$/; if(state_re.test(state_val) == false) { alert("enter valid state name"); document.registration.ustate.focus(); return false; } } //country validation var country_val=document.registration.ucountry.value; if(country_val=="") { alert("enter country name"); document.registration.ucountry.focus(); return false; } else if(country_val!='') { var country_re =/^[-A-Za-z. ]*$/; if(country_re.test(country_val) == false) { alert("enter valid country name"); document.registration.ucountry.focus(); return false; } } //login name validation var lname_val=document.registration.lname.value; if(lname_val=="") { alert("enter username "); document.registration.lname.focus(); return false; } //password validation var pass_val=document.registration.pass.value; if(pass_val=="") { alert("enter password"); document.registration.pass.focus(); return false; } else if(pass_val!="") { var invalid = " "; var minLength = 6; if (pass_val.length < minLength) { alert("Your password must be at least " + minLength + " characters long"); document.registration.pass.focus(); return false; } if (pass_val.indexOf(invalid) > -1) { alert("Sorry, spaces are not allowed."); document.registration.pass.focus(); return false; } } //checkbox if (document.registration.chk[0].checked == false && document.registration.chk[1].checked == false && document.registration.chk[2].checked == false) { alert ("select checkbox"); return false; } } </script> </head> <body> <?php include("data.php"); if(isset($_POST["reg"])) { $name=$_POST['uname']; $mail=$_POST["email1"]; $city=$_POST['ucity']; $state=$_POST['ustate']; $country=$_POST['ucountry']; $uname=$_POST['lname']; $passwd=$_POST['pass']; $inr=mysql_real_escape_string(implode(",",$_POST["chk"])); if(mysql_query("insert into register(name,email,city,state,country,username,password,interest) values ('$name','$mail','$city','$state','$country','$uname','$passwd','$inr')")) $good="You have successfully registered,you can login now"; else $bad="error:".mysql_error(); } mysql_close($cn); ?> <br /> <strong style="background-color:#00CCFF"> REGISTRATION FORM</strong> <br /><br /> <form action="register.php" method="post" name="registration"> <table border="0" width="600" height="600" align="left"> <tr><td>Name:</td><td><input type="text" name="uname"/></td></tr> <tr><td>Email:</font></td><td><input type="text" name="email1" /></td></tr> <tr><td>City:</font></td><td><input type="text" name="ucity" /></td></tr> <tr><td>State:</td><td><input type="text" name="ustate" /></td></tr> <tr><td>Country:</td><td><input type="text" name="ucountry" /></td></tr> <tr><td>Username:</td><td><input type="text" name="lname" /></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" /></td></tr> <tr><td>Intrest: <input name="chk[]" id="chk[]" type="checkbox" value="reading" />Reading <input name="chk[]" id="chk[]" type="checkbox" value="sports" />Sports <input name="chk[]" id="chk[]" type="checkbox" value="travel" />Travel </td></tr> <tr><td> <input type="submit" name="reg" value="ok" style="cursor:pointer;" onclick="return regval();" /> <?php if(isset($good)) {?> <input type="button" value="Login" onclick="javascript:window.location='loginpage.php'" style="cursor:pointer;" /><br /><br /><?php }?> </td></tr> </table> <?php if(isset($good)) echo $good; if(isset($bad)) echo $bad; ?></strong></font> </form> </div> </body> </html> 17377_.php
-
I have page with male female radio button Here's the code $qry=mysql_query("SELECT * FROM reg_table where id=$id "); $res=mysql_fetch_array($qry); $radio = $res['gender']; switch($radio) { case "male": $mal = "checked"; break; case "female": $fem = "checked"; break; } Gender: <br /> <input type="radio" name="colour" value="male" checked="<?php $mal; ?>" />Male <input type="radio" name="colour" value="female" checked="<?php $fem; ?>" />Female Whats the use of checked in <input type="radio" name="colour" value="male" checked="<?php $mal; ?>" />
-
I want to delete record which i clicked the delete button in the table. I want a confirm box for delete Help me solve.. Here is code display.php <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("register",$cn); $qry2=mysql_query("SELECT * FROM reg_table"); ?> <html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Do you want to Delete?"); if (r==true) { } else { alert("You pressed Cancel!"); } } </script> </head> <body> <form action="delete.php" method="get"> <table width="200" border="1"> <tr> <th scope="col">Name</th> <th scope="col">Address</th> <th scope="col">Gender</th> <th scope="col">Qualify</th> </tr> <?php while($res=mysql_fetch_array($qry2)) {?> <tr> <td><?php echo $res['name']; ?></td> <td><?php echo $res['adrs']; ?></td> <td><?php echo $res['gender']; ?></td> <td><?php echo $res['qualify']; ?></td> <td> <a href="edit.php?uid=<?php echo $res['id']; ?>">edit</a></td> <!--<td> <button type="button" onClick="return show_confirm();">Delete</button> </td> --> <td> <input type="hidden" name="nid" value="<?php echo $res['id']; ?>" /> </td> <td> <input type="submit" value="Delete" name="del" onClick="return show_confirm();"> </td> </tr> <?php } ?> </table> </form> </body> </html> delete.php <html> <body> <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("register",$cn); $del_id=$_GET['nid']; $qry=mysql_query("delete from reg_table where id='".$del_id."' ") or die(mysql_error()); if($qry) { echo "deleted"; } else { echo "not deleted"; } ?> <!--<form action="update.php" method="get"> <br /> Name: <input name="name" type="text" maxlength="20" /><br /><br /> <input type="hidden" name="uno" value="// echo $id; "> <input name="submit" type="submit" value="Save" /> </form> --> </body> </html>
-
Hi!! I want to delete record which i clicked the delete button in the table. I want a confirm box for delete Here is code display.php <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("register",$cn); $qry2=mysql_query("SELECT * FROM reg_table"); ?> <html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Do you want to Delete?"); if (r==true) { } else { alert("You pressed Cancel!"); } } </script> </head> <body> <form action="delete.php" method="get"> <table width="200" border="1"> <tr> <th scope="col">Name</th> <th scope="col">Address</th> <th scope="col">Gender</th> <th scope="col">Qualify</th> </tr> <?php while($res=mysql_fetch_array($qry2)) { ?> <tr> <td><?php echo $res['name']; ?></td> <td><?php echo $res['adrs']; ?></td> <td><?php echo $res['gender']; ?></td> <td><?php echo $res['qualify']; ?></td> <td> <a href="edit.php?uid=<?php echo $res['id']; ?>">edit</a></td> <td> <input type="hidden" name="nid" value="<?php echo $res['id']; ?>" /> </td> <td> <input type="submit" value="Delete" name="del" onClick="return show_confirm();"> </td> </tr> <?php } ?> </table> </form> </body> </html> delete.php <html> <body> <?php $cn=mysql_connect("localhost","root",""); mysql_select_db("register",$cn); $del_id=$_GET['nid']; $qry=mysql_query("delete from reg_table where id='".$del_id."' "); if($qry) { echo "deleted"; } else { echo "not deleted"; } ?> </body> </html>
-
whats the diff between echo,print,print_r what's the difference between include(),require,require_once
-
ya <?php session_start(); ob_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Signin</title> </head> <?php include("data.php"); $user_err=''; $pass_err=''; if(isset($_POST['submit'])) { $user=$_POST['user']; $passwd=$_POST['pass']; $err=0; if($user=="") { $user_err="enter username"; $err=1; } if($passwd=="") { $pass_err="enter password"; $err=1; } if($err==0) { $check=mysql_query("select username from register where username='$user'")or die(mysql_error()); $check2=mysql_num_rows($check); if($check2==0) { $uer="User does not exist,enter correct username"; } else { $check1=mysql_query("select password from register where username='$user' and password='$passwd'")or die(mysql_error()); $check2=mysql_num_rows($check1); if($check2==0) { $per="Password mismatch,enter correct password"; } else { $_SESSION['user']=$user; $_SESSION['password']=$passwd; header("location:msg.php"); } } } mysql_close($cn); } ?> <body> <br /><br /> <form method="post" action="loginpage.php"> <table bgcolor="#6699FF" width="500" height="300" align="center"> <tr><td align="center"> <strong>Sign in with your account</strong><br /><br /><br /> USERNAME:<input type="text" name="user" value="" /> <br /><br /> PASSWORD:<input type="password" name="pass" value=""/> <br/><br/> <input type="submit" value="login" name="submit" /> </td></tr> </table> </form> </body> </html>
-
when user login to his account, I want to expire session after 5 minutes
-
where to use and when to use $_request whats the use of $_request