Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
echo "Click Here";
Can someone please fix this? I keep getting errors and i really am confused...
I'm trying to make it so it echos a changed url using a form.
My form:
<body>
<h1>Enter Player Name.</h1>
<form method="post" action="handler.php">
<input type="text" name="player">
<input type="submit">
</form>
</body>
If you can, can you tell me how to make it so when the "Submit" button is pressed it auto redirects them in a new tab to the edited url? If you could, it would be amazing!
This should do the trick. When using quotation marks you can put the PHP variable direction inside the string. Then you can change the quotes around the url to single quotes so it doesn't close out of the string.
echo "<a href='http://bans.scavengercraft.com/index.php?action=viewplayer&player=$_POST[player]&server=0'>Click Here</a>";
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have been trying to send some basic form information from my index page to a .php page without success. I have tweaked my code looking at the previously asked questions but to no avail.
I have another form on the same page which sends information to another .php page which works without flaw.
My form page code:
<form name="login" action="login.php" method="post">
<p>email: <input type="text" name="loginEmail"></p><br>
<p>password: <input type="password" name="loginPass"></p>
<button type="submit"> Submit!</button>
</form>
my login.php page code:
<?php
echo "test";
$email=$POST_["loginEmail"];
echo $email;
?>
All I see on my login.php page is "test".
Thanks.
Switching the location of the _ should do it:
<?php
echo "test";
$email=$_POST["loginEmail"];
echo $email;
?>
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am testing PHP and the variable from the form is not staying, and does not appear even on the same page. Here is the code:
<?php
echo "<form action='input.php' method='post'>Test: <input type='text' name='last' </form><input type=submit>";
echo "<h1>The last input was: </h1>", $_POST["last"];
?>
This is not a PHP problem. It is an HTML problem.
Your submit button is outside of the form.
It's effectively "submitting" a blank, empty, made-up form of its own.
That made-up form does not contain any of your data.
Move the submit button to inside of the form.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I can't figure out the syntax for quotes within quotes within quotes.? (edit: was not a matter of this, had an echo where it should be concatenated. See my answer below for corrected code)
This code brings a syntax error
$stringData="<?echo'<form method=\"post\" action=\"<? echo$_SERVER['PHP_SELF'];?>\"><button type=\"submit\">';?>";
I've tried many combinations of quotes and backslashes.
What is the proper syntax?
Bad grammar. This should work ;)
If you want to echo it:
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'"><button type="submit">';
If you want to keep it on a variable:
$string = '<form method="post" action="'.$_SERVER['PHP_SELF'].'"><button type="submit">';
I simply had an echo where it shouldn't be. Sorry for wasting your time.
$stringData="<?echo'<form method=\"post\" action=\" .'\$_SERVER['PHP_SELF']'.\"><button type=\"submit\">';?>";
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I have tried to echo the button, however the link just does not work, so I thinks something is wrong with the href link, please help.
echo "<input class='button_normal' type='button' value='entertainment' onclick='window.location..href=<Electronic and Entertainment Products.php>'>";
#james_91 The code below should do the trick:
<?php
echo "<input class=\"button_normal\" type=\"button\" value=\"entertainment\" onclick=\"window.location.href='Electronic and Entertainment Products.php'\">";
?>
I would advise against using spaces in your file names so use underscores instead maybe.
JS within a button within PHP works best with escaped quotation marks, you also had two dots in between location and href as commented by Fred -ii-
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
We are using this link to delete data from an MySQL database, but when we launch it in the browser we get an error that something is wrong with this line.
Could someone say what's wrong with it?
echo "<a href=delete_hardware.php?id=<?php.$rows['hardwareID']; ?>>delete</a>";
Here is the correct link, with quotes and concatenation :
echo 'delete';
Try this:
echo "delete";
The problem is that you're using a link to perform a destructive action.
Never, ever, ever, EVER use <a href...> to perform an action. Especially not a "delete" action.
GET requests imply that they may be performed at any time, without any need for confirmation. POST requests, on the other hand, imply one-time use. This is why when you reload a page you opened through a link, that's fine, but try to reload a page you submitted with a form? HOLD ON THERE, are you sure you want to resubmit because you might end up buying the same item twice!
Therefore, your code should be:
?>
<form action="delete_hardware.php" method="post">
<input type="hidden" name="id" value="<?=intval($rows['hardwareID'])?>" />
<input type="submit" value="delete" onClick="return confirm('Are you SURE you want to delete this?');" />
</form>
<?php