how to echo $_SERVER['PHP_SELF'] within a string [closed] - php

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\">';?>";

Related

How to Concatenate a PHP variable and a string [closed]

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
might be a very dumb question but i'm trying to make a html string with a php var and then html.. what the heck am I doing wrong?!? :(
$author_name = get_the_author(); ?>
<h4><?php $author_name;?> On-Demand Webinars</h4>
Thank you!
Just missed the echo.
<h4><?php echo $author_name;?> On-Demand Webinars</h4>
You missed "echo" statement
e.g
<?php echo $author_name;?> On-Demand Webinars
OR
<?=$author_name;?>

Action in form using PHP [closed]

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 a problem. Because i'm new in PHP, i don't know whether this is right or wrong syntax. Form it's not working.
<form name="edit_client" method="post" action="index3.php?page=del&id=<?php echo $row['id']; ?>&action=edit">
No problem with that.
<form name="edit_client" method="post" action="index3.php?page=del&id=<?php echo $row['id']; ?>&action=edit">
Just missed a = after id

PHP echo button with on-click wont function well [closed]

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-

Echoing html code in php [closed]

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
I am trying to echo the following code in html but it deosn't seem to work.
echo '<input type="submit" value="Click!" style="width:100px;" onclick="$('#loading').show();"/>'
Please help
You have overlapping of ' quote inside the JavaScript. You need to escape the single quote like this:
echo '<input type="submit" value="Click!" style="width:100px;" onclick="$(\'#loading\').show();"/>'
// Notice the backslashes? ^ ^

Can someone fix my php echo statement? [closed]

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>";

Categories