Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions php/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

?>



30 changes: 30 additions & 0 deletions php/my.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
$conn = mysqli_connect('localhost','root','password','test');

if(!$conn){
echo 'eeror'.mysqli_connect_error();
}
$sql = 'select * from user_info';
$sql2 = "insert into user_info values('chocho')";

// mysqli_query($conn,$sql);
$result = mysqli_query($conn,$sql);
$names = mysqli_fetch_all($result,MYSQLI_ASSOC);
//$single = mysqli_fetch_assoc($result);
// $single2 = mysqli_fetch_assoc($result);
print_r($single2);
foreach($names as $key=>$value)
{
print_r($value);
echo "<br/>";
}
//print_r($names);

// $arr = explode('@','himanshu@dewan.com');


// list($username,$domain) = $arr;
// $assoc = compact('username','domain');
// print_r($assoc);

?>
44 changes: 44 additions & 0 deletions php/q1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
// $name = $_REQUEST['user_input'];
// global $count ;
// $count = 10;
// echo $name;
// if(0==false){
// echo 'oh shit';
// }
//echo strrchr("My is name i hmanhu","is");
// echo nl2br("One line.\nAnother line.");
// $n = 4;

// echo "<table border='1px'>";
// for($i=0;$i<4;$i++)
// {
// echo "<tr>";
// for($j=0;$j<4;$j++)
// {
// echo "<td>".$i*$j."</td>";
// }
// echo "</tr>";
// }
// echo "</table>";

echo $_SERVER['REMOTE_PORT'];


?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action='/q1.php' method='get'>
<input name='user_input'/>
<input type='submit' />
</form>
</body>
</html>
20 changes: 20 additions & 0 deletions php/q10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
if($_POST['1']>=$_POST['2'] && $_POST['1']>=$_POST['3'] ){
echo $_POST['1'];
}
else if($_POST['2']>=$_POST['3']){
echo $_POST['2'];
}
else {
echo $_POST['3'];
}


?>

<form method='post'>
<input type='number' name='1'/>
<input type='number' name='2'/>
<input type='number' name='3'/>
<input type='submit' />
</form>
16 changes: 16 additions & 0 deletions php/q11.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
function my_fact($num){
if($num==1 || $num == 0){
return 1;
}
else return $num * my_fact($num-1);
}

echo my_fact($_POST['1']);

?>

<form method='post' >
<input type='number' name='1' />
<input type='submit' />
</form>
27 changes: 27 additions & 0 deletions php/q12.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

function prime($n){

for($i=2;$i<=$n-2;$i++){
if($n%$i==0){
return false;
}
}
return true;
}
if(isset($_POST['1'])){
if(prime($_POST['1'])){
echo 'prime';
}
else{
echo 'notprime';
}
}

?>

<form method='post'>
<input type='number' name='1' />
<input type='submit' />

</form>
16 changes: 16 additions & 0 deletions php/q13.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
$n = $_REQUEST['1'];
for($i=0;$i<2*$n;$i++){
if($i%2==0){
echo $i,'<br>';

}
}

?>

<form method='post'>
<input type='number' name='1' />
<input type='submit' />

</form>
18 changes: 18 additions & 0 deletions php/q14.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
$n = $_REQUEST['1'];
$s = 0;
for($i=0;$i<2*$n;$i++){
if($i%2==1){
$s+=$i;

}
}
echo "sum is:",$s;

?>

<form method='post'>
<input type='number' name='1' />
<input type='submit' />

</form>
29 changes: 29 additions & 0 deletions php/q15.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

if(isset($_POST['1'])){
$a = $_POST['1'];
$f=true;
for($i=0,$j=strlen($a)-1;$i<$j;$i++,$j--){
if($a[$i]!=$a[$j]){
echo 'not pali';
$f = false;
break;
}

}
if($f==true){
echo 'pali';
}


}



?>

<form method='post' >
<input name='1' />

<input type='submit' />
</form>
23 changes: 23 additions & 0 deletions php/q16.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
function fib($n){
if($n==0||$n==1){
return $n;
}
else return fib($n-1)+fib($n-2);
}
$n = $_REQUEST['1'];
for($i=0;$i<$n;$i++){
echo fib($i),'<br>';
}


?>




<form method='post' >
<input type='numbers' name='1' />

<input type='submit' />
</form>
17 changes: 17 additions & 0 deletions php/q17.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
$n = $_REQUEST['1'];
for($i=0;$i<$n;$i++){
for($j=0;$j<$i;$j++){
echo "*";
}
echo '<br>';
}

?>


<form method='post' >
<input type='numbers' name='1' />

<input type='submit' />
</form>
6 changes: 6 additions & 0 deletions php/q2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$var = [23,2,1,32];
sort($var);
echo print_r($var);

?>
42 changes: 42 additions & 0 deletions php/q3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
if(isset($_POST['choice'])){
if($_POST['choice']==1){
$str = $_POST['string'];
echo $str . '<br/>';
echo str_replace(' ','',$str);

}
elseif($_POST['choice']==2){
$str = $_POST['string'];
$substr = $_POST['string2'];
echo strpos($str,$substr);
}
elseif($_POST['choice']==3){
$str = $_POST['string'];
if(preg_match('/^[A-Z+]$/',$str))
echo 'UpperCase';
elseif(preg_match('/^[a-z+]$/',$str))
echo 'LowerCase ';
else
echo 'Contains Special Character';
}
elseif($_POST['choice']==4){
echo preg_replace('/the/','that',$string,1);
# echo str_replace()


}
}
?>


<p>1.Remove White Spaces</p>
<p>2.String Contains another String</p>
<p>3.Check if it is lowercase</p>
<p>4.Replace first the with that</p>
<form method='post'>
Choice: <input name='choice' /><br>
String:1 <input name='string' /><br>
String 2<input name='string2' /><br>
<input type='submit' value='sunmit' />
</form>
30 changes: 30 additions & 0 deletions php/q4.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
$today = date("Y-m-d");
$bdate=$_REQUEST['date'];
$birth_time=strtotime($bdate);
$current_time=strtotime($today);
$arr1=explode('-',$bdate);
$bday_year=$arr1[0];
$arr2=explode('-',$today);
$today_year=$arr2[0];

$year_diff=$today_year-$bday_year;

$new_time=strtotime("+".$year_diff." year",$birth_time);
if($new_time<$current_time){
$new_time=strtotime("+1 year",$new_time);

}
$time_diff=$new_time-$current_time;
$days=$time_diff/(86400);
echo "Hurray!, only $days left in your birthday ";


?>

<form method='post' >

<input type='date' name='date' />
<input type='submit' value='submit' />

</form>
5 changes: 5 additions & 0 deletions php/q5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
$a = array('red','green','white');
sort($a);
print_r($a);
?>
31 changes: 31 additions & 0 deletions php/q6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
switch($_POST['lang']){
case 'hindi':
echo 'नमस्ते';
break;
case 'english':
echo 'hello';
break;
case 'Telegu':
echo "హలో !";
break;
case 'Urdu':
echo "ہیلو !";
break;
}


?>


<form method='post' >
<select name='lang' >
<option value='hindi'>Hindi</option>
<option value='english'>English</option>
<option value='Telegu'>Telegu</option>
<option value='Urdu'>Urdu</option>
<input type='submit'/>

</select>

</form>
Loading