I want a new page to be opened when a button is pressed. Here is my code so far:
<input name="newThread" type="button" value="New Discussion" onclick="window.open('Political/Thread/thread_insert.php')"/>
It fails, however, ..I think the path is incorrect, but I dont know why..cause it is the correct directory path...
This will open a new tab/window (depending on the user's settings):
<a class="button" href="Political/Thread/thread_insert.php" target="_blank">New Discussion</a>
To make this "a button":
a.button {
border: 1px solid #808080;
background: #a0a0a0;
display: inline-block;
padding: 5px;
}
Your code is correct (valid and function), you problem is the your path.
Remember that page location is the page inside the web server and relative to the current page location.
So if your web server root is for example c:\wamp\www then the web address test/test.php will look for the real page of c:\wamp\www\test\test.php. However the same address encoded into a page already in a subdirectory will be relative unless it starts with /
So from the page test/test.php in the above example the link to test/test.php will become /test/test/test.php (with a real path of c:\wamp\www\test\test\test.php)
If you have copied the link from another page somewhere this is probably the problem
Try the below code,
<INPUT type="button" value="Click" onClick="window.open('Political/Thread/thread_insert.php','windowname',' width=400,height=200')">
Try this:
<form action="Political/Thread/thread_insert.php" target="_blank" action="post">
<input name="newThread" type="submit" value="New Discussion" />
</form>
Tested and working. You can leave the action empty if you want.
Or
<form action="Political/Thread/thread_insert.php" target="_blank" action="">
<button>New Discussion</button>
</form>
But as said in one of the other answers, you better go with a link and style it like a button. Using javascript or making forms to achieve the same results is just more work and well... bad.
Use this
Join
class="btn
btn is the style class of the button.
And f you want a direct link to the file and not have to go into an external folder:
Join
I hope this helps
Add below properties to element and it will look exactly same as button
Disable text-decoration for link for better effect
align-items: flex-start;
text-align: center;
cursor: default;
box-sizing: border-box;
padding: 2px 6px 3px;
border-width: 2px;
border-style: outset;
border-image: initial;
-webkit-appearance: push-button;
-webkit-user-select: none;
white-space: pre;
text-rendering: auto;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
margin: 0em 0em 0em 0em;
font: 13.3333px Arial;
I know it's too late but I'm putting it for other people who is looking for the same answer
if(isset($_POST['myButtonName'])){
header("Location:newPage.php");
exit();
}
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<button style="margin-left:5px;" type="submit" class="btn btn-primary" name="myButtonName">Open</button>
</form>
Related
i recieved the following code for a button that i wanted to add on my Website. When i click on it it forwards me to the Website on the same Page but i want it to open a new tab with the Website
(add "<" at start to try the code)+
<a
class="button"
style="
background-color: #24baef;
color: #1c212e;
font-size: 14px;
font-weight: 600;
padding: 3.5px 17.5px;
border-radius: 5px;
"
href="https://www.youtube.com/"
>
Button
</a>
Best Regards,
Danowick
Use target attribute "_blank" inside of your anchor tag.
<a class="button" style=
"background-color: #24baef;
color: #1c212e;
font-size: 14px;
font-weight: 600;
padding: 3.5px 17.5px;
border-radius: 5px;"
href="https://youtube.com/" target="_blank">
For more reference:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
https://www.w3schools.com/tags/att_a_target.asp
Hey i want to put this into href link in this button how to input that
\"/led=ON\"\"
This is button code with animation
<button type="button" class="btn btn-primary btn-cons btn-animated from-top fa fa-arrow-up"><span>Open</span></button>
To give you a very bare-bones example of my comment above (formatting a link as a button), here is a decent place to start. Feel free to format it however you want of course.
HTML Hyperlink:
Example
CSS Class:
.linkLikeButton {
display: inline-block;
border: 2px solid black;
padding: 10px;
background-color: steelblue;
color: white;
text-decoration: none;
}
.linkLikeButton:hover {
background-color: lightblue;
}
I'm using this tutorial on nettuts to build a contact form. Their contact form works fine on a mac that's running on 10.6.8 but doesn't work on a mac running on 10.8.4? I'm assuming it might be something to do with version of PHP but I'm not sure how to fix their code to make it paly nice can anyone help? I have also tried it on my websites server but no joy there either.
thanks,
Instead of php, you can use a button with a mailto: tag
.button {
background-color: #ffa200;
border: none;
color: white;
padding: 15px 410px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button:hover
{
background-color:#ff2f00;
}
a.a
{
text-decoration: none;
}
h3.k
{
color: white;
font-weight: bold;
}
<center>
<button class="button">
<a class="a" href="mailto: name#example.com"><h3 class="k">SEND US A MESSAGE</h3></a>
</button>
</center>
This tag opens the Mail app and already shows who it is to
I am developping a job appliance form, that outputs its results into a CRM (Customer Relationship Management).
My problem is that my client wants the fields "Street Adress, Postal Code and locality" outputted all together in one single field in CRM, after inputted in different fields on the form.
So i thought i should use php for when the user clicks on submit it gets the value of each one of the fields and inputs it into an hidden field i created.
for some reson, as i am not a php expert, it isn't working.
It is really not outputting any value into the CRM
this is what i've got so far:
<form action="https://service.capsulecrm.com/service/newlead" method="post">
<input name="morada" id="morada" maxlength="255" title="" style="border-style: solid; border-width: 1px; border-color: #cccccc; position: absolute; margin: 0px; padding: 0px; width: 220px; height: 20px; font-family: Tahoma; font-size: 11px; color: #333333; background-color: #ffffff; z-index: 1; left: 189px; top: 397px;" value="" type="text">
<input name="postal" id="postal" maxlength="255" title="" style="border-style: solid; border-width: 1px; border-color: #cccccc; position: absolute; margin: 0px; padding: 0px; width: 220px; height: 20px; font-family: Tahoma; font-size: 11px; color: #333333; background-color: #ffffff; z-index: 1; left: 189px; top: 437px;" value="" type="text">
<input name="local" id="local" maxlength="255" title="" style="border-style: solid; border-width: 1px; border-color: #cccccc; position: absolute; margin: 0px; padding: 0px; width: 220px; height: 20px; font-family: Tahoma; font-size: 11px; color: #333333; background-color: #ffffff; z-index: 1; left: 189px; top: 467px;" value="" type="text">
<?php if ($_POST['submit']) {
$addressmorada = $_POST['morada'];
$addresspostal = $_POST['postal'];
$addresslocal = $_POST['local'];
echo "<input type='hidden' name='STREET' value='".$addressmorada. " " .$addresspostal. " " .$addresslocal."' />";
}
?>
<input name="submit" type="submit" value="Submit" style="
border-style: none; border-width: 0px; border-color: #888888; position: absolute; margin: 0px; padding: 0px; width: 93px; height: 33px; z-index: 1;
left: 433px; top: 1773px;
text-indent: 99999999999999px;
background: green;
cursor: pointer;
">
</form>
I will try to explain my PHP code,
the if statement it's calling the function on submit.
the variables get the different input values.
I echo an input field type hidden, calling the variables, so that all the information is outputted into the CRM in one single field
I think the major problem may be on number 3! i'l apreciate any help.
Sory if my english is bad, it's not my mother language.
two issues:
1,
if ($_POST['submit'])
will throw an error: Notice: Undefined index: submit in ... if there is no $_POST data.
it should be changed to
if (isset($_POST['submit']))
2, $_POST['submit'] will never occur as there is no name attribute called submit. You should add this to your "submit" button:
<input type="submit" value="Submit" name="submit" style="[STYLES_HERE]">
You don't have a name for you button right.
<input type="submit" value="Submit" name = "submit" >
You have
if ($_POST['submit']).
So the name of the button should be submit. Otherwise it will never go in your if statement.
For debugging purpose
Try just printing all the values in the if statement. Its helpful.
You're confusing server-side and client-side code. Here's a simple explanation, though you should document yourself more about HTTP and the way web servers work:
when a user A requests a page, a HTTP request is sent to the server
this request is handled by a web server B
according to some rules (file extension, file location, ...), the web server can decide to simply fetch the file and send it to the client A (e.g. for a plain HTML file), or run it through a (PHP) interpreter first and then send the result to the client.
in any case, the client A receives only the HTML: the PHP has already been executed by B at this point.
So the user requests the page with the form. At this point he didn't submit anything yet, so the PHP interpreter gets nothing in $_POST and the hidden input is empty.
The user fills the form and submit it. That triggers a new HTTP request with the data. But of course the hidden input is still empty, and will never get filled because the PHP has already been executed (and won't ever be client-side).
What you need to do is either
modify the target script (https://service.capsulecrm.com/service/newlead) if you have access to it, in order to join the fields together
if you can't, add an intermediate PHP script which is the target of the form, join the fields together and send a HTTP request itself (e.g. with curl) to newlead
or if you don't want to spend too much time on that, use client-side code, that is Javascript, to fill the hidden input. However you can't be sure the form will be submitted correctly (the user can choose to disable Javascript, or the client may not handle it at all: this is common for Braille devices).
I am a little bit lost. What I want to achieve is:
my own custom button
change onMouseOver etc'
keep it's size
post the information to a php server side code
What I'm missing is:
The post - I couldn't figure out how to combine js & php
The Button size - my code sets a size for the original button but after the rollover it changes
The code:
<html>
<head>
</head>
<body>
<script>
function form_on_click(frm)
{
document.buttonMore.src='bottom_more_click.JPG';
frm.submit();
}
</script>
<div style="position: absolute; left: 120px; top: 90px; background-image: url(myBackgroundPicture.jpg);
background-repeat:no-repeat; width: 800px; height: 280px; padding: 15px;">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="whatever" size= "55" height="100" lang="en" dir="ltr" style="margin-top: 188px; margin-left: 95px; height: 20px; background-color: transparent; border:none;
color: #FFFFFF; font-family: Verdana; font-weight: none; font-size: 18px;">
<a onmouseover="document.buttonMore.src='bottom_more_hover.JPG'"
onmouseout="document.buttonMore.src='bottom_more_reg.JPG'"
onmousedown= "form_on_click(this.form) this.form.submit()"
onmouseup="document.buttonMore.src='bottom_more_hover.JPG'">
<img src="bottom_more_reg.jpg" name="buttonMore" height="30" width="173" border="0" alt="MORE!" style="margin-bottom:-10px; margin-left: 15px; height: 30px; width: 100px;">
</a>
</form>
</div>
</body>
UPDATED:
Oh sure.. excuse me. You're totally right. I don't know where do I have my head.
Try something else, remove this line again
onmousedown= "form_on_click(this.form) this.form.submit()"
And replace it by
href="javascript:form_on_click(this.form);"
Just a suggestion, why don't you use an...
<input type="button" />
...and then customize it in CSS?
EDIT
About the size of the button, are those jpeg files equally sized?
The easiest way would be to use JQuery. All of what you want to do can be done with just a few simple steps in JQuery. The mouseover/out submit all of it and tons more.
I fell in love with JQuery...