Jump to content

voip03

Members
  • Posts

    693
  • Joined

  • Last visited

Posts posted by voip03

  1. Missing <php ?> code in form .

    <?php
    $host="localhost";
    $username="root"; 
    $password="";
    $db_name="dbreg";
    $tbl_name="account"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");$sql="SELECT * FROM $tbl_name";
    $result=mysql_query($sql);
    echo "<table border=\"5\" width=\"400\" >";echo "<tr><th>List of Student to be approve</th>";    
    if(mysql_num_rows($result))     {     while($row = mysql_fetch_assoc($result))     { 	echo "<tr><td>";    
    echo "<input type='checkbox' name='list[]' value='".$row['Username']."'>".$row['famname'].",".$row['gname']. ",".$row['mname']. ".<br/></td>";     
    echo "</tr></input>";   } 	
    
    }    else {		    echo "<tr><td align=\"center\"> No Student to be Approve / Reject </td></tr>";      } 	
    echo'</form>';
    ?>

  2. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Documents and Settings\Ken\Desktop\xampplite\htdocs\Pages\valval3.php on line 49

    Have you connected to your MySQL database ?

     

     

  3.  

    <?php

     

      //calculate years of age (input string: YYYY-MM-DD)

      function birthday ($birthday){

        list($year,$month,$day) = explode("-",$birthday);

        $year_diff  = date("Y") - $year;

        $month_diff = date("m") - $month;

        $day_diff  = date("d") - $day;

        if ($day_diff < 0 || $month_diff < 0)

          $year_diff--;

        return $year_diff;

      }

     

    echo birthday('1960-06-14');

     

    ?>

     

  4. This is only example

     $sql = "SELECT usename FROM USER WHERE username ='". $_POST['username']."'";
    $res = mysql_query($sql);
    if(!res){ 	die(" Could not query the database  : <br/>". mysql_error() ); }
    $numRows =  mysql_num_rows($res);
    
    if( $numRows != 0 )
    {
    	// ? check the passowrd
    }
    else
    {
    	// ! username error
    }
    

  5. 1. read this topic

    http://www.phpfreaks.com/forums/index.php?topic=37442.0

     

    2. place this code top of the code

    	/*
     "Warning: Cannot modify header information - headers already sent by "
      	To avoid the header error , give value zero to
    	$mosConfig_locale_debug = 0;
    	$mosConfig_locale_use_gettext = 0;
    */
    $mosConfig_locale_debug = 0;
    $mosConfig_locale_use_gettext = 0;
    ob_start();
    

    3.Open the windows and shout ' header sucks! '

    AND start Re arranging the logics and code.

     

  6. your code

    $headers = 'From: noreply@abc.com' . "\r\n" .    'Reply-To: noreply@abc.com' . "\r\n" .    'X-Mailer: PHP/' . phpversion();
    

    Replace this code

    		$headers = "MIME-Version: 1.0\r\n";
    	$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
    	$headers.= "From: $from\r\n";
    

  7. 1st try this code.

    once you happy with it then  start  your one.

    <?php
    
    if (isset($_POST['submitted']) && !empty($_POST['myusername']) && !empty($_POST['mypassword'])) 
    { 
    	//check for submit button click 
    	$username = $_POST['myusername'];   
    	$password = $_POST['mypassword']; 
    
    	// NOTE  - quick check
    	$_SESSION['username'] = $username;
    
    	echo "Hello ".$_SESSION['username'];
    
    
    	// remove '/* */ ' when the st test result is OK.
    
    	/*
    	// proceed with rest of code
    	$self = $_SERVER['PHP_SELF'];
    	$referer = $_SERVER['HTTP_REFERER'];			
    
    	#if either form field is empty return to the log-in page
    	if( (!$username ) or (!$password ) ){ header(  "Location:$referer" ); exit(); }
    
    	#connect to mysql
    	$conn = @mysql_connect( "server", "username", "password" )		or die( "Could not connect" );
    	#select database 
    	$rs = @mysql_select_db( "removalspacelogin", $conn )			or die ( "Could not select db" );
    	#create query
    	$sql="select * from users where username = '". $username."' and upassword = '".$password."'";
    	#execute query
    	$rs = mysql_query( $sql, $conn )		or die( mysql_error() );
    	if($rs){   $_SESSION['username'] = $username;}
    	#get number of rows that match username and password
    	$num = mysql_numrows( $rs );
    	#if there is a match the log-in is done
    	if( $num != 0 ){ header( "Location:login_success.php" ); }
    	else 
    	{ header( "Location:$referer" ); exit(); }}
    
    	*/
    }
    else
    {
    ?>
    <?php ini_set("display_errors","ON"); ?>
    <html><head><title>Check-login</title></head>
    <body> 
    <?php echo( $msg ); ?> 
    
    <form action="#" method="post">
    <fieldset>
    <legend>Login</legend>
    
    <p>Username: <input name="myusername" type="text" size="60" maxlength="100" /></p>
    
    <p>Password: <input name="mypassword" type="password"  size="60"/></p>
    <!--   
    The hidden input here is a trick I use to check for a form’s submission. 
    Doing this is sometimes necessary as just pressing Enter within Internet Explorer
    for Windows will submit a form withoutever setting the $_POST['submit']variable.
    -->
    <input name="submitted" type="hidden" value="true" />
    <input name="submit" type="submit" value="Login" />
    
    </form>
    </body> 
    <?  } ?>
    </html>
    
    

  8. Citing W3Schools for a programming question is worse than citing Wikipedia for a research paper. W3Fools

    But sometimes their examples are simple and easy to understand

    And sometimes those very same examples are wrong. Sure, one in a handful is good, but people new to the content won't be able to tell what is and what isn't.

    Yes, you are correct. I will stop referring.

×
×
  • 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.