I want to add a variable Email address into the link (so email address dynamically fills when someone hit the link), which re-direct PHP. Email addresses are different based on person visited the link. So I am wondering, how can I in ordinary URL address add variable Email, which will then intervened and added to PHP re-direct?
This is the code, but not working...
<?PHP
$subid=$_GET[subid];
$email=$_GET[email];
?>
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://xentrk.com/?a=41&c=308&s1={{ email|default:'null' }}<?PHP echo $subid;?>" />
</head>
<body>
You are using echo $subid in your URL:
Surely this should be $email ?
In which case this is the code:
<?php
$subid=$_GET['subid'];
$email=$_GET['email'];
?>
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://xentrk.com/?a=41&c=308&s1={{ email|default:'null' }}<?php echo $email;?>" />
</head>
<body>
Related
I have a page with element <a> acting like a <button>, in this form the elements works like a service plans, and i want to get a value when one of these buttons has been clicked.
Page1.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page 1</title>
<?php
session_start();
?>
</head>
<body>
<section>
Choose Plan1
<br><br>
Choose Plan2
<br><br>
Choose Plan3
</section>
</body>
</html>
Page2.php
<?php
session_start();
echo 'test';
echo $_POST['name'];
?>
I know that $_POST['name'] doesn't works cuz don't exist a input, but i don't know how use something like this to get a value of button clicked and show this value.
The return expected for first button for example, is something like:
basic
I need this value to put in database after.
Someone can help me to get this values?
You may pass the value as a url parameter
<section>
<a href="page2.php?plan=basic" >Choose Plan1</a>
<br><br>
Choose Plan2
<br><br>
Choose Plan3
</section>
And get it from $_GET in your php code
echo $_GET['plan'];
I am trying to create a option list , using a input field. The input field submits the data to my databse and in the same time i create a new file with the name of the value that i added in the input field and attach a exetension of ".php" to create a php file. Also together with the value i send also the file path into the database. In the index.php you can see the following code:
INDEX.PHP
<?php
include "conn.php";
$query="SELECT DISTINCTname,filePath FROM name_data";
$res=mysqli_query($conn,$query);
?>
<!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>
<select name="select_list" id="list" onchange="location=this.value">
<?php foreach($res as $name){?>
<option value="<?php echo $name['filePath'];?>"><?php echo $name['name'] ;?></option>
<?php };?>
</select><br><br>
<form action="set.php" method="post">
<input type="text" name="name"><br><br>
<input type="submit" name="submit"><br><br>
</form>
</body>
</html>
And for the form submission i use the following code. Now in this example i dont use RegEx for the input field its just a simple code that i am trying:
SET.PHP
<?php
include "conn.php";
if(isset($_POST['submit'])){
$name=$_POST['name'];
$path=$name.".php";
$query="INSERT INTO name_data(name,filePath) VALUES('$name','$path')";
if(mysqli_query($conn,$query)){
header("LOCATION:index.php");
}
fopen($path,"w");
};
Now What i want to do, when i query the database i want the value(name) from the form submission to be linked to the corresponding file path(file Path) that i created during form submission.
How can I get an HTML value to send to PHP. I would like to avoid using a form. For example I have an input:
<input name="input" id="input">Input</input>
while in PHP:
$input = $_POST['input'] --> but didn't work
or
$input = $_GET['input'] --> still didn't work
I know that I will be able to get it using form then action="another file" but I want it within a file. Please help. Thank you.
If you simply want to use js to append the input value in url variable then you can use js function as follows;
client.php
<!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>
<input type="text" id="txt">
<a onclick="append()" id="anch" href="server.php?text">Send value</a>
</body>
</html>
<script>
function append()
{
txt=document.getElementById('txt');
anch=document.getElementById('anch');
anch.href=anch.href+"="+txt.value;
}
</script>
server.php
$variable = $_GET["input"];
echo $variable;
Output on localhost:
After clicking send value:-
Update: I just read the end of your question. If you want to show the value of input on same page/file then you can use following code;
<!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>
<input type="text" id="txt">
<?php
if(isset($_GET['text']))
{
$text=$_GET['text'];
echo "<a onclick='append()' id='anch' href='?text=$text'>Enter Value</a>";
}
else
{
echo "<a onclick='append()' id='anch' href='?text'>Enter Value</a>";
}
?>
<br>
<?php
if(isset($_GET['text']))
echo "<div id='values'>".$_GET['text']."<div>";
?>
</body>
</html>
<script>
function append()
{
txt=document.getElementById('txt');
anch=document.getElementById('anch');
if(anch.href.match(/=/)=="=")
anch.href=anch.href+txt.value+"<br>";
else
anch.href=anch.href+"="+txt.value+"<br>";
}
</script>
Output:
Check output on phpFiddle
It seems that the way to go is to use the GET method.
You will need to access your page with the get parameters included like this:
http://localhost/index.php?input=VALUE_HERE
And in your php file:
$variable = $_GET["input"];
echo $variable;
But if you insist to use inline html elements to get data, you need to use javascript for that like this for jquery:
alert("This is the value of the input" + $("#input").val());
Don't use this
<input name="input" id="input">Input</input>
Use this
<input name="input" id="input">
I am new in using PHP - i am trying to get the data from data sent to the Apache server using $_POST - but i am getting nothing
below is the details
i am using XAMPP on Windows 7 for setup (Apache & PHP)
and I am having two files
welcome.html which is calling welcome.php to echo the contents got from the html
Note that I have nothing reported in Apache error log file
C:\xampp\apache\logs\error.log
any idea what went wrong here
<head>
<meta charset="utf-8"/>
</head>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
<input type="submit">
</form>
</body>
and
welcome.php
<?php
error_reporting(E_ALL);
?>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
</head>
<body>
Welcome
<?php echo $_POST["name"]; ?><br>
</body>
for testing your php file. direct run this welcome.php from your localhost
like this http://localhost/welcome.php
<?php
echo 'Check your name';
?>
if you see "Check your name"; then your local server is working . else need to run local server
this is your html welcome.html file
<head>
<meta charset="utf-8"/>
</head>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
<input type="submit">
</form>
then submit your form using name text
then check your code using
<?php
error_reporting(E_ALL);
print_r($_POST);
?>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
</head>
Welcome
everything work here
I have three pages One with HTML with the form (input variable) and its going to POST the variable to linkslvl2.php . With my third page i want to use the GET function and retrieve the variables from linkslvl2.php. When i click on the process i want it to automatically process linkslvl2 and print linkslvl3 statement. I'm stumped on how to pass it the variables along.
<!doctype html>
<html>
<head>
</head>
<body>
<h1 style="text-align:center;"> Super Hero</h1>
<form action="linklvltwo.php" method="post">
Please Enter a name:
Enter A super Hero Name:
Enter your weakness:
<!doctype html>
<html>
<head>
</head>
<body>
<?php
$name = $_POST['namep'];
$superHero = $_POST['superhero'];
$weakness = $_POST['weakness'];
?>
</body>
</html>
<!doctype html>
<html>
<head>
</head>
<body>
<?php
$person = $_GET['name'];
$chosenhero = $_GET['superHero'];
$chosenweakness = $_GET['weakness'];
print"
<p>$person you have chosen $chosenhero as you super hero, and your weakness $chosenweakness</p>
"
?>
</body>
</html>
perhaps you can try using $_REQUEST which gives you the parameters wether they are posted or "getted".
I think you can do this type of works in two way: 1) you can use db, file, session to save the value after submitting each form and use an id to indentify/get the previous values. 2) you can Submit the values of each steps via