Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI have built a PHP contact form on wordpress that redirects user based upon his/her selected region.
I have used 'www.google' as a test URL.
However, the form is not getting redirected and staying on the same page after submitting.
Where am I going wrong?
Please find the code below:
<?php
if(isset($_POST['submit']))
{
$region = $_POST['Region'];
switch ($region )
{
case 'North': $url = '/'; break;
case 'South': $url = '/'; break;
case 'East': $url = '/'; break;
case 'West': $url = '/'; break;
}
if(!empty($url))
{ header('Location: '+ $url);
}
}
?>
<html>
<head>
<title> Meal Planner </title>
</head>
<body>
<form action="<?php the_permalink(); ?>" method="POST">
<p>Name</p> <input type='text' name='cp_name'>
<p>Email</p> <input type='text' name='cp_email'>
<p>Phone</p> <input type='text' name='cp_phone'>
<p>Dropdown Box</p>
<select name='Region' size='1'>
<option value='North'>North
<option value='South'>South
<option value='East'>East
<option value='West'>West
</select>
<br />
<input type='submit' name="submit" value='SUBMIT'><input type='reset' value='CLEAR'>
</form>
</body>
</html>
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionI have built a PHP contact form on wordpress that redirects user based upon his/her selected region.
I have used 'www.google' as a test URL.
However, the form is not getting redirected and staying on the same page after submitting.
Where am I going wrong?
Please find the code below:
<?php
if(isset($_POST['submit']))
{
$region = $_POST['Region'];
switch ($region )
{
case 'North': $url = 'https://www.google/'; break;
case 'South': $url = 'https://www.google/'; break;
case 'East': $url = 'https://www.google/'; break;
case 'West': $url = 'https://www.google/'; break;
}
if(!empty($url))
{ header('Location: '+ $url);
}
}
?>
<html>
<head>
<title> Meal Planner </title>
</head>
<body>
<form action="<?php the_permalink(); ?>" method="POST">
<p>Name</p> <input type='text' name='cp_name'>
<p>Email</p> <input type='text' name='cp_email'>
<p>Phone</p> <input type='text' name='cp_phone'>
<p>Dropdown Box</p>
<select name='Region' size='1'>
<option value='North'>North
<option value='South'>South
<option value='East'>East
<option value='West'>West
</select>
<br />
<input type='submit' name="submit" value='SUBMIT'><input type='reset' value='CLEAR'>
</form>
</body>
</html>
Share
Improve this question
asked Jan 19, 2020 at 17:31
Bot123Bot123
11 silver badge2 bronze badges
1 Answer
Reset to default 1Because the url is not correct.
The +
sign is for concatenating strings in javascript language. You should use .
sign.
header('Location: ' . $url);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744820802a4595605.html
评论列表(0条)