Wednesday 6 June 2018

$POST Request in php







<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>post</title>

</head>



<body>



<form method="post">

Name:<input type="text"  name="name"/ >

Email:<input type="text"  name="email"/ >



<button type="submit" value="submit">  submit</button>



</form>



<?php

if($_SERVER['REQUEST_METHOD']=="POST")

{

$name=$_POST['name'];

$email=$_POST['email'];



if(empty($name) || empty($email))

{

echo "<p style='color:red'> * </p>";



}

else

{

echo "<p style='color:green'> Name: ".$name." </p>";

echo "<p style='color:green'> Email: ".$email." </p>";

}



}

?>







</body>

</html>

$_Get method in php (Super Global variable)





<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>Untitled Document</title>

</head>



<body>

<form method="get">

<input type="text" name="fname"/>

<input type="text" name="email"/>

<button type="submit" value="submit"> Submit </button>



</form>



<?php



if($_SERVER['REQUEST_METHOD']=="GET")

{

$name= $_GET['fname'];

$email= $_GET['email'];

if(empty($name) || empty($email) )

{

echo "<P style='color:red'> No name present..... </p>";



}

else

{

echo "<P style='color:red'> Name : ".$name." </p>";



echo "<P style='color:red'> email : ".$email." </p>";

}



}

?>





</body>

</html>

SUPER GLOBAL VARIABLE IN PHP $server and $Global





<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>GLOBAL</title>

</head>



<body>

<?php

$x=10;

$y=20;



function myfun()

{

$GLOBALS['x']=$GLOBALS['x']+$GLOBALS['y'];



//echo "value of x = ".$x;



}

myfun();

//echo "value of x = ".$x;

echo "PHP REFERENCE=".$_SERVER['HTTP_REFERER'];

?>







<?php

echo $_SERVER['PHP_SELF'];

echo "<br>";

echo $_SERVER['SERVER_NAME'];

echo "<br>";

echo $_SERVER['HTTP_HOST'];

echo "<br>";

echo $_SERVER['HTTP_REFERER'];

echo "<br>";



?>





</body>

</html>

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...