<button onclick="location.href='<?php echo base_url();?>Guesser/guess'">Start!</button>
Just displays an empty web page with about:blank as the url
Try this:
<input type="button" onclick="location.href='<?php echo base_url();?>Guesser/guess'" value="Start!">
Related
Help, how to open link like https://www.google.com using php header while code in local server? im using localhost
my php code:
<?php
if(isset($_GET['kirim'])){
header("Location: https://www.google.com/");
}
?>
my html code:
<div class="col-md-4 col-sm-4">
<button type="submit" name="kirim" class="btn btn-default">Reservation via Whatsapp</button>
</div>
and after i clicked the button always show blank page
blank page after clicked the button
i want open google.com link or whatsapp link after click the button
In the form element of your HTML code you define the action of the data submission. In this case the method is POST and the URL of your action is your PHP file "crud/confirm-process.php":
HTML code
<form action='crud/confirm-process.php' method='POST' >
<div class="col-md-4 col-sm-4">
<button type="submit" name="kirim" class="btn btn-default">Reservation via Google</button>
</div>
</form>
PHP code in crud/confirm-process.php
<?php
if(isset($_POST['kirim'])){
header("Location: https://www.google.com/");
}
?>
I already have some items in the cart. I want to remove them all. So, I've created a submit button with post method called 'remove_all', following doesn't work, it says "The requested URL was not found on this server." Can please someone help me?
<?php
if (isset($_POST['remove_all'])){
unset($_SESSION['cart']);
echo "<script>window.location = 'cart.php'</script>";
}
?>
And here what I wrote in my index.php
<form action="remove_all" method="post" class="cart-items">
<button type="submit" value="Очистить всё" name="remove_all" class="btn btn-danger mx-2">Очистить всё</button>
</form>
It looks like you you not linking properly to your remove_all.php file. Try this:
<form action="/remove_all.php" method="post" class="cart-items">
<button type="submit" value="Очистить всё" name="remove_all" class="btn btn-danger mx-2">Очистить всё</button>
</form>
Also in your PHP file, you do not need to mix PHP and js - simply change header as following:
<?php
if (isset($_POST['remove_all'])){
unset($_SESSION['cart']);
// echo "<script>window.location = 'cart.php'</script>";
header("Location: cart.php");
}
?>
I want to call a method in my controller class at a button press. want to know how this should be corrected. or is there any other reason that this won't work.
<?php echo form_open('form/SearchUser');?>
<button type="submit" class="btn btn-default">Search</button>
<?php echo form_close();?>
I have home_c controller, home_m model and home_v view page in code igniter application folder. My view home_v page contains following code.
<?php
echo form_open('home_c/save');?>
Name:<input type="text" name="name" value="">
<input type="submit" name="sub" value="Save">
<?php echo form_close();?>
<?php
echo form_open('home_c/view');?>
<input type="submit" name="view" value="View">
<?php echo form_close();?>
My problem is that, I could not execute function view() in controller home_c. But I can execute same function by placing instead of the view button. I don't know what is the real issue behind this. Anybody please help me to solve this issue.
If you want different action for each button, use the a href = base_url 'Controller/Method'.. Like this one, button type = "button" a href=" base_url() . 'Controller/Method'
if($this->input->post('sub')=='Save'){
$this->your_model->add($data);
}
if($this->input->post('view')=='View'){
$this->load->view('view',$data);
}
Change like this and check
hi i want to have two submit button in one form in code igniter. is it possible? i want to make two buttons which will do the same thing, add data into the database, the only difference of the buttons is on which page they will redirect.
here is my codes,
<?php
echo form_open('EmpFamilyInfo/add_childinfo/'.$this->uri->segment(3));
?>
// some textboxex,
<div class="box-body">
<div class = 'col-md-6 col-sm-offset-6'>
<button class="btn btn-info fa fa-save" type="submit">  Save</button>
<a href = '<?php echo base_url().'EmpFamilyInfo/other_childinfo/'.$this->uri->segment(3); ?>' class = 'btn btn-primary fa fa-save' >  Add Another</a>
<a href = '<?php echo base_url().'EmpFamilyInfo/parentsinfo_father/'.$this->uri->segment(3); ?>' class = 'btn btn-danger fa fa-arrow-circle-right'>  Skip</a>
<?php
echo form_close();
?>
</div>
</div>
i have made this code which the first link echo form_open('EmpFamilyInfo/add_childinfo/'.$this->uri->segment(3)); what i wanted this to do is
public function other_childinfo(){
$this->form_validation->set_rules('NAME', 'Name of Child' ,'trim|required|max_length[100]');
if($this->form_validation->run($this) == FALSE){
$this->child_info();
}else{
if($query = $this->EmpFamilyInfo_Model->insert_childinfo()){
redirect('EmpFamilyInfo/child_info/'.$this->uri->segment(3));
}else{
$this->child_info();
}
}
}
but the error is,that it does not have post data. how can i make this link a submit button but it will go to different function or how can i make it have the post data?
this question ahs been answered already on this site, so this response is not mine, just quoting for you:
This uses javascript so keep in mind users who have this disabled will not be able to use this solution.
<script type="text/javascript">
function submitForm(action)
{
document.getElementById('form1').action = action;
document.getElementById('form1').submit();
}
</script>
...
<input type="button" onclick="submitForm('page1.php')" value="submit 1" />
<input type="button" onclick="submitForm('page2.php')" value="submit 2" />