Bachu 45 Newbie Poster

When I test your code like

<?php

class DateTest {

 public function inputEndDate() {
    $value = date('Y/m/d');
    $html = "";
    $html .= '<label for="enddate">End Date:</label>' . PHP_EOL;
    $html .= '<input type="text" readonly name="enddate" id="enddate" value="'.$value.'">';
    $html .= '<input type="button" id="enddatebutton" onclick="getEndDate()">' . PHP_EOL;
    return $html;
}


public function inputExpiryDate() {
    $value = date('Y/m/d');
    $date = date('Y/m/d', strtotime("$value +6 month"));
    $html = "";
    $html .= '<label for="expirydate">Expiry Date:</label>';
    $html .= '<input type="text" readonly name="expirydate" id="expirydate" value="'.$date.'">';
    $html .= '<input type="button" id="expirydatebutton" onclick="getExpiryDate()">' . PHP_EOL;
    return $html;
}

}

$dateClass = new DateTest();
echo $dateClass->inputEndDate();
echo $dateClass->inputExpiryDate();
?>

It works fine..

You check the value of

 $value = $this->endDate;
Bachu 45 Newbie Poster

Check this

else {

// form submitted 
// set server access variables 
$host = "localhost"; 
$user = "root"; 
$pass = ""; 
$db = "books";

$search = empty($_POST['search'])? die ("ERROR: Enter Search Criteria") : mysql_escape_string($_POST['search']); 
$dropdown = empty($_POST['dropdown'])? die ("ERROR: Select from dropdown") : mysql_escape_string($_POST['dropdown']);

// Open Connection

$connect = mysql_connect($host, $user, $pass) or die ("Unable to connect to host");

//Select Database

mysql_select_db($db) or die ("Unable to connect to database");

//Create Query

$query = "SELECT * FROM books WHERE $dropdown='$search'" or die (mysql_error());

$result = mysql_query($query) or die (mysql_error());

$num=mysql_numrows($result);

mysql_close($connect);

echo "<b><center>Search Results of Bounced Checks</center></b><br><br>";

echo "<table width = '1000' align = 'center' border ='1'>";

echo "<tr><td>Check ID</td><td>Transaction Date</td><td>Store Name</td><td> Check Date</td><td>Date Cashed</td><td>Date Return</td><td>Check Number</td><td>Maker Name</td><td>Payee Name</td><td>Bank Name</td><td>Check Amount</td><td>Return Reason</td><td>Date Solved</td><td>Redeposited</td><td>Replacement</td><td>Paid Cash</td><td>Balance</td><td>Disposition</td></tr>";


$i=0; 
while ($i < $num) {

$bookid=mysql_result($result,$i,"bookid"); 
$transactiondate=mysql_result($result,$i,"transactiondate"); 
$storename=mysql_result($result,$i,"storename"); 
$checkdate=mysql_result($result,$i,"checkdate"); 
$datecashed=mysql_result($result,$i,"datecashed"); 
$datereturn=mysql_result($result,$i,"datereturn"); 
$checknumber=mysql_result($result,$i,"checknumber"); 
$makername=mysql_result($result,$i,"makername"); 
$payeename=mysql_result($result,$i,"payeename"); 
$bankname=mysql_result($result,$i,"bankname"); 
$checkamount=mysql_result($result,$i,"checkamount"); 
$returnreason=mysql_result($result,$i,"returnreason");
$datesolved=mysql_result($result,$i,"datesolved");
$redeposited=mysql_result($result,$i,"redeposited");
$replacement=mysql_result($result,$i,"replacement");
$paidcash=mysql_result($result,$i,"paidcash");
$balance=mysql_result($result,$i,"balance");
$disposition=mysql_result($result,$i,"disposition");

echo "<tr>";
            echo "<td>".$bookid."</td>";
            echo "<td>".$transactiondate."</td>";
            echo "<td>".$storename."</td>";
            echo "<td>".$checkdate."</td>";
            echo "<td>".$datecashed."</td>";
            echo "<td>".$datereturn."</td>";
            echo "<td>".$checknumber."</td>";
            echo "<td>".$makername."</td>";
            echo "<td>".$payeename."</td>";
            echo "<td>".$bankname."</td>";
            echo "<td>".$checkamount."</td>";
            echo "<td>".$returnreason."</td>";
            echo "<td>".$datesolved."</td>";
            echo "<td>".$redeposited."</td>";
            echo "<td>".$replacement."</td>";
            echo "<td>".$paidcash."</td>";
            echo "<td>".$balance."</td>";
            echo "<td>".$disposition."</td>";


echo "</tr>";
$i++;
} 
echo "</table>";
} 
?>

</body> 
</html> 
Bachu 45 Newbie Poster

Try this

<?php
if (isset($_POST['generator'])) {
$charset = 'absdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789%$#-()*&.,';
$generated_password = substr (str_shuffle($charset),0, 12);
}
?>
<form action ="" method="post">
<input type="submit" name="generator" value="Generate"><input type="text" value="<?php if (isset($generated_password)) {echo $generated_password; } ?>"/>
</form>
rayidi commented: This will exactly what andyy121 need :) +2
Bachu 45 Newbie Poster

Try this

$pass = md5($_POST['password']);
$id_user= $_POST[username];

$login = mysql_query("SELECT * FROM user WHERE id_user='$id_user' AND sesi='$pass'");
$found = mysql_num_rows($login); 
Bachu 45 Newbie Poster

Exg:

In your Form ..

<input type="checkbox" name="chk[]" value="1" />
<input type="checkbox" name="chk[]" value="2" />
<input type="checkbox" name="chk[]" value="3" />

In action page

<?php
if($_POST['chk']) {
$chekedValues=  array();
$chekedValues = $_POST['chk'];
$append="";
foreach ($chekedValues as $key=>$value) {
            $append.=($key==0) ? 'WHERE ' : 'OR';
            $append.= " db_table_field_name="."'".$value."'";
}

$sqlsearch = mysql_query("SELECT * FROM db_table_name ".$append);

    while ($row = mysql_fetch_array($sqlsearch))
        {

        }
}
?>
Bachu 45 Newbie Poster

Try this

<?php
$sqlsearch = mysql_query("SELECT * FROM tblteacher_info WHERE Fname='$iFName' AND Mname='$iMName' AND Lname='$iLName'",$open_con);
    if(!$sqlsearch)
        {
            die("Database connection failed:" . mysql_error());
        }

else {
            if(mysql_num_rows($sqlsearch)>0) {

                $i_sqlupdate = mysql_query("UPDATE tblteacher_info SET Fname='$iFName', Mname = '$iMName', Lname = '$iLName', Username ='$username', Password='$password' WHERE Lname = '$iFName' AND Mname ='$iMName' AND  Lname = '$iLName'  ",$open_con);

                if(!$i_sqlupdate)
                    {
                    die("Error in saving: ". mysql_error());
                    }
            }

            else
            {
                $i_sqlinsert= mysql_query("INSERT INTO tblteacher_info (Teacher_ID, Fname, Mname, Lname, Username, Password) VALUES ('0', '$iFName', '$iMName', '$iLName', '$username', '$password')",$open_con);

                if(!$i_sqlinsert)
                    {
                    die("Error in saving: ". mysql_error());
                    }

            } 

}
?>
Bachu 45 Newbie Poster

Exg:

<?php
$txtName=$_POST['txtName'];
$txtEmail=$_POST['txtEmail'];
$fileName=$_POST['fileName'];
$txtIndustry=$_POST['txtIndustry'];
$txtCountry=$_POST['txtCountry'];
$txtCompensation=$_POST['txtCompensation'];
$currentPage=$_POST['currentpage'];
$host=$_SERVER['HTTP_HOST'];
$download='<tr><td colspan="2">Downloads: <a href="http://'.$host.'/filepath/'.$fileName.'"  target="_blank" >'.$fileName.'</a></td></tr>';


$enquiry='<table width=700 border=0 cellspacing=2 cellpadding=2 align=center>
<tr><td align=right width=100>Name: </td><td>'.$txtName.'</td></tr>
<tr><td align=right width=100>Email: </td><td>'.$txtEmail.'</td></tr>
<tr><td align=right width=100>Industry: </td><td>'.$txtIndustry.'</td></tr>
<tr><td align=right width=200>Preferred Country: </td><td>'.$txtCountry.'</td></tr>
<tr><td align=right width=200>Expected Compensation: </td><td>'.$txtCompensation.'</td></tr>
'.$download.'
</table>';

$headers = "MIME-Version: 1.0" . "\r\n";

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

$headers .= "From:info@your.com\r\n";

$user="info@your.com";

mail($user,"Your Web Info", $enquiry, $headers);

?>
Bachu 45 Newbie Poster

A Simple methode is

upload your file to your server location and take that uploaded file path.
Attach this filepath to your mail content for download this file.

Bachu 45 Newbie Poster
if($_POST['add_marks'] ==1)
{
include('includes/connect.php');
$bots = array();
$mts = array();
$eots = array();

$bots =$_POST['bot'];
$mts=$_POST['mt'];
$eots=$_POST['eot'];

    foreach($bots as $key=>$bot)
    {
    $insert = "INSERT INTO marks(beginning_of_term,mid_term,end_of_term) VALUES('$bot','$mts[$key]','$eots[$key]')";
    $execute_insert = mysql_query($insert);
    }
}
Bachu 45 Newbie Poster
<?php
$sql=mysql_query("SELECT * FROM `products` where tf=1 and star='7' ORDER BY `id` DESC");
$inc = 0;
while($r=mysql_fetch_array($sql)){
    $inc++;
    $id=$r['id'];
    ?>
<div style="width:152px; height:205px;">

<?php echo $id; ?>
</div>
<?php 
    if($inc%4==0) echo '<hr />';
} 
?>

Here I have seperated each 4 items by hr tag.. This will help you... to know how to
seperte items.

mahdiyazdani commented: Thanks +0
Bachu 45 Newbie Poster

In form

<tr bgcolor="<?php echo $bg; ?>">
                  <td><?php  echo $rows['firstName']." ".$rows['lastName']." ".$rows['otherName'];  ?></td>
                  <td><?php  echo $rows['regNo']; ?></td>
                  <td><?php  echo $rows['class']." ".$rows['stream']; ?></td>
                    <td><div align="center"><input type="text" name="bot[]" size="10" /></div></td>
                  <td><div align="center"><input type="text" name="mt[]" size="10" /></div></td>
                  <td><div align="center"><input type="text" name="eot[]" size="10" />
                  <input type="hidden" value="<?php echo $rows['school_id']; ?>" name="schoolId[]"> 
                  </div></td>
              </tr>

In action page

if($_POST['add_marks'] ==1)
{
include('includes/connect.php');
$bots =$_POST['bot'];
$mts=$_POST['mt'];
$eots=$_POST['eot'];
    foreach($bots as $key=>$bot)
    {
    $insert = "INSERT INTO marks(beginning_of_term,mid_term,end_of_term) VALUES('$bot','$mts[$key]','$eots[$key]')";
    $execute_insert = mysql_query($insert);
    }
}
broj1 commented: Nice and concise +6
Bachu 45 Newbie Poster
<?php
$database_value='a';
$chka = ($database_value=='a') ? 'checked' : '';
$chkb = ($database_value=='b') ? 'checked' : '';
$chkc = ($database_value=='c') ? 'checked' : '';
?>

<input type="checkbox" name="chka" <?php echo $chka; ?> value="a" />
<input type="checkbox" name="chkb" <?php echo $chkb; ?> value="b" />
<input type="checkbox" name="chkc" <?php echo $chkc; ?> value="c" />
Bachu 45 Newbie Poster

In form.php

<html>
<body>

<form action="number.php" method="post">

Enter number: <input type="text" name="number" /><br /><br />

Enter number to Add: <input type="text" name="add" /><br /><br />

Enter number to Subtract: <input type="text" name="subtract" /><br /><br />

Enter number to multiply: <input type="text" name="multiply" /><br /><br />

Enter number to divide: <input type="text" name="divide" /><br /><br />

<input type="submit" value="Submit">

</form>

</body>
</html>

In number.php

<?php
$number = (isset($_POST['number']) && $_POST['number']!="") ? $_POST['number'] : '0';
print "\$number = ".$number.";<br />";
$number += $_POST['add'];
print "\$number += ".$_POST['add'].";<br /> The answer is <b>$number</b>. <br /><br />";

$number -= $_POST['subtract'];
print "\$number -= ".$_POST['subtract'].";<br /> The answer is <b>$number</b>. <br /><br />";

$number *= $_POST['multiply'];
print "\$number *= ".$_POST['multiply'].";<br /> The answer is <b>$number</b>. <br /><br />";

$number/= $_POST['divide'];
print "\$number /= ".$_POST['divide'].";<br /> The answer is <b>$number</b>. <br /><br />";

?>
LastMitch commented: Thanks for the example! +5
Bachu 45 Newbie Poster
<?php
$targetPath = $_SERVER['DOCUMENT_ROOT'].'/upload/';

if (isset($_POST['submit'])){

$filename = basename( $_FILES['file']['name'], ".pdf");

if($_FILES['file']['type']=='application/pdf') {
        $filename = preg_replace("/[^A-Za-z0-9_-]/", "", $filename).".pdf";
        $thumb = basename($filename, ".pdf");
        $cpy=1;
        do {
            $targetFile =  str_replace('//','/',$targetPath) ."Copy".$cpy. $filename;
            $filename="Copy".$cpy. $_FILES['file']['name'];
            $cpy++;
        }while(is_file($targetFile));

            if(move_uploaded_file($_FILES['file']['tmp_name'], $targetPath.$filename)) {             
                    $pdfWithPath = $targetPath.$filename;
                    echo "File Uploaded Successfully";
            }
}
else {
    echo "Please Upload pdf File";  
}
}

?>

<form method="post" action="" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" name="submit" value="Upload" />
</form>

Check your $targetPath path is correct and give 777 permission for folder upload

Bachu 45 Newbie Poster
<?php
session_start();


# We require the library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
    'appId'  => 'XXXXXXXXXXXXXXX',
    'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    'cookie' => true
));

$session = $facebook->getSession();
if ($session) {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
    $friends = $facebook->api('/me/friends');
}


foreach ($friends as $key=>$value) {
    echo '<ul id="friendsList">';
    foreach ($value as $fkey=>$fvalue) {
    if($fvalue->gender == "female") {
    echo '<li>$fvalue->name </li>';
}   
    }
    echo '</ul>';
}
?>
Bachu 45 Newbie Poster

1; set $searchResult= array();

2; Check each tables and push all results to the array $searchResult, like below

$sql="SELECT   *  FROM    df_restaurent WHERE  (df_restaurent.Address  LIKE '%$query1%' )  GROUP BY RestaurentId ;";

                   $result=$this->db->query($sql);
                   $data=$this->db->fetchAll($result);
                   foreach($data as $dd)
                     {      
                 array_push($searchResult, array( "Page" => "RestaurentDetails", "RestaurentId"=>"$dd->RestaurentId" ));

                     }

3; At the end of cheking of all tables , return $searchResult

Bachu 45 Newbie Poster
<html>
<head>
<title>currency Convert</title>
</head>
<body>
<?php
$amount = (isset($_POST['amount'])) ? $_POST['amount'] : 0;
$slt1 = (isset($_POST['form']) && $_POST['form']=="taka") ?  'selected="selected"'  : '';
$slt2 = (isset($_POST['form']) && $_POST['form']=="rupe") ?  'selected="selected"'  : '';
$slt3 = (isset($_POST['form']) && $_POST['form']=="inr") ?  'selected="selected"'  : '';
?>
<form action="" method="POST">
      <table>
         <tr>
         <td>
             <lebel>$</label>
             <input type="text" name="amount"  value="<?php echo $amount; ?>"  />
             to <select name="form">
                          <option <?php echo $slt1;?> value="taka">taka</option>
                          <option <?php echo $slt2;?> value="rupe">rupe</option>
                          <option <?php echo $slt3;?> value="inr">inr</option>

             </select>
             <input type="submit" value="convert"/>
         </td>
         </tr></form>
         <tr>
         <td>
<?php
 if(isset($_POST['amount'])) {
 $amount=$_POST['amount'];
 $currencyCode=$_POST['form'];
 if($amount>0){
    if($currencyCode=='taka') {
    $currency = $amount*80;
    echo "you converted Amount $".$amount. " = ".$currency."Tk";

     }
    elseif($currencyCode=='rupe'){
    $currency = $amount*20;
    echo "you converted ammount $".$amount. " = ".$currency."Rup";
    }
    elseif($currencyCode=='inr'){
    $currency = $amount*10;
    echo "you converted ammount $".$amount. " = ".$currency."Inr";
    }

 }
 else
 echo 'enter your ammount';
 }
         ?>
         </td>
         </tr>


      </table>
</body>
</html>
Bachu 45 Newbie Poster
Bachu 45 Newbie Poster

date ('d/m/y \a\t H:i');

OR

date ('d/m/y').' at '.date('H:i');

Bachu 45 Newbie Poster

Get the status of that check box from your DB table.You may be saved that in 0(not checked) or 1 (checked).Check this status when you update the profile. Exg:

<input type="checkbox" name="chkBx"  <?php  echo ($yourCheckBoxStatus== "0") ?  'checked="checked"'  : '' ; ?> value="0" />
Bachu 45 Newbie Poster

ok;

change the htaccess like this

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)-(.*)$ /site/profile.php?page=$1&id=$2 [L]

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site/profile.php?page=$1 [L]
</IfModule>

then in profile.php

    <?php

    if(isset($_REQUEST['page']) && $_REQUEST['page']=="profle") {
    $page= (isset($_REQUEST['id']) || $_REQUEST['id'] != "")? $_REQUEST['id'] : "index";
    include_once($page.".php");

    }

    ?>

And set url like

www.mysite.com/profle-signout
Bachu 45 Newbie Poster

Hi

RewriteRule ^index$ index.php [L]
RewriteRule ^newuser$ newuser.php [L]
RewriteRule ^newsite$ newsite.php [L]
RewriteRule ^newadver$ newadver.php [L]
RewriteRule ^signout$ signout.php [L]
RewriteRule ^signin$ signin.php [L]
RewriteRule ^profile$ profile.php [L]

No need to add this in your htaccess file

For signout give url like ***www.mysite.com/signout ***
And for other links use following URL's

  • www.mysite.com/newuser
  • www.mysite.com/newadver
  • www.mysite.com/signin etc...
Bachu 45 Newbie Poster

You can't run php file like html file.You need test server(WAMP/XAMP) for testing php code.

<?php
function yourname($name)
{
    echo "Your name is " .$name;
}

yourname("andi");

$age= 18;

if ($age>=21)
{
    echo ' alan';
}
else{
    echo ' bob';
}

?>
Bachu 45 Newbie Poster

Yes , it is possible.

First you create a table for saving login time, an unique id and log out time.

When a user login creates a unique id and save it in a session.

Then insert the login time and unique id to the table.

When user logged out, takes unique id session and updates this table with this session and logged out time. After updating, unset session.

Then you will get login time and logout time.

Bachu 45 Newbie Poster

Using hidden varable, u can pass values or post values

Like

<input type="hidden" name="id" value="<?php echo $yourId; ?>" />
Bachu 45 Newbie Poster

You need to set the row fields name as an array.
You should know the javascript or jquery for appent each rows without page load.

Bachu 45 Newbie Poster
<?php

$images = array('T1.jpg','I2.jpg','M3.jpg','E4.jpg');

$alt = array('Time','To','Tell','Toke');

foreach($images as $key=>$image) {
    echo '<img src="images/'.$image.'" alt="'.$alt[$key].'" />';
}

?>
Bachu 45 Newbie Poster
Bachu 45 Newbie Poster
Bachu 45 Newbie Poster

You need a uploading-folder with file permission 777 ... we use jquery uploadify for file upload
http://www.uploadify.com/documentation/

Bachu 45 Newbie Poster
Bachu 45 Newbie Poster
Bachu 45 Newbie Poster

You need to install CURL. Check this link

http://www.php.net/manual/en/curl.setup.php

Bachu 45 Newbie Poster

1; Set index.php

<!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>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>

<body>

<?php
session_start();
echo $timezone = $_SESSION['timezone'];

?>
</body>
</html>
<script type="text/javascript">
    $(document).ready(function() {
        if("<?php echo $timezone; ?>".length==0){
            var visitortime = new Date();
            var visitortimezone = "GMT " + -visitortime.getTimezoneOffset()/60;
            $.ajax({
                type: "GET",
                url: "http://www.yoursite.php/time.php",
                data: 'timezone='+ visitortimezone,
                success: function(){

                    location.reload();
                }
            });
        }
    });
</script>

2; Set time.php

<?php
    session_start();
    $_SESSION['timezone'] = $_GET['timezone'];
?>
diafol commented: Don't copy somebody else's code and supply it as your own. A link is sufficient -3
Bachu 45 Newbie Poster

http://www.uploadify.com/ this link will help you

Bachu 45 Newbie Poster
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site/inner.php?page=$1 [L]
</IfModule>

1;First you create a page inner.php

2;Set htacess with above code

3;Set inner.php

<?php
$page= (isset($_REQUEST['page']) || $_REQUEST['page'] != "")? $_REQUEST['page'] : "index";
include_once($page.".php");
?>

**NB: the resquested page name should be same as your file name **

eg: www.yoursite.com/register , there should be a file with file name register.php

Bachu 45 Newbie Poster

Check this

function check($width, $position, $base_string, $charSet,$combinations)
{
    for ($i = 0; $i < strlen($charSet); $i++) 
    {
        if ($position  < $width - 1) 
         $combinations .= check($width, $position + 1, $base_string.$charSet[$i], $charSet, $combinations);            

       $combinations .= $base_string . $charSet[$i].'-';
    }

        return $combinations;
}

$word = "Hel";

$combinations = check(strlen($word), 0, "", $word, '');
$values = array_unique(explode("-", $combinations));

foreach ($values as $value)
    echo $value.'<br />';
Bachu 45 Newbie Poster

You can also use ,

//Upload excel file:
$_FILES["car_info_file"]["type"] == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ...