l have a index file of my website in
localhost-->mywebsite-->index.php (this is my external script)
and i have build a registration form with codeigniter.
I can use the registration form using url http://localhost/codeigniter/index.php/form.
But how can i attach that registration form into my website index file.
using include_once"../codeigniter/index.php/form"; in my external php script(index.php of my website) is not working.
However if i make that 'form' the default controller file and use the following code from external php script
include_once "codeigniter/index.php"; it works well. but what if i need other controller files but not just 'form'?
Update:
I can also link to that file from external php script as:
<a href="codeigniter/index.php/form>Register</a>.
But not include. Whenever i include it displays no such file.
So if i understood you correctly you want to use codeigniter's form in some other php website, actually idea to do such thing is wrong (as you can't normally control your form action link etc better to build same for in other website directly), but answer for your question is following trick
Place this code in your other website where you want to have codeigniter form included
$output = shell_exec('php ABSOLUTE_PATH/codeigniter/index.php form index');
// where "ABSOLUTE_PATH" is absolute path to your codeigniter project
// "form" is your controller name
// "index" action name
echo $output; // will echo form html generated by codeigniter
In localhost-->mywebsite-->index.php, you could try this:
<?php include_once('/codeigniter/index.php/form'); ?>
If not you can move your index.php code into a codeigniter view and set it up that way.
try using below code...
<?php $data = file_get_contents("http://localhost/codeigniter/index.php/form/");
$html_encoded = htmlentities($data);
echo $html_encoded;
?>
In the above code we get all contents of the url in $data variable and then use htmlentities on that for html encoding...
Related
I have created an HTML form which calls a php page (function) when submitted:
<form name="business" action="create-account-and-profile.php" method="POST">
<table>
<tbody>
....
I have made sure that create-account-and-profile.php is in the same directory. The php file is a form data processor which starts as follows:
require_once (ABSPATH . "wp-admin/includes/user.php");
if (isset($_POST['personal_email_id'])) {
$email_id = $_POST['personal_email_id'];
.......
For some reason unknown to me, when the form is submitted, a “404 not found” error was generated.
This is on a WORDPRESS platform, hosted in the Openshift environment.
I searched and reviewed relevant posts on this and WORDPRESS forums.
Any advice will be greatly appreciated.
JZ
You must check that create-account-and-profile.php is in the same relative path of HTML page containing the form. e.g.:
if you form is in
example.com/subdir/form.html
the php file must be in
example.com/subdir/create-account-and-profile.php
Have you tried opening the create-account-and-profile.php page simply by typing the URL into your browser? If you can't reach the page that way the problem is probably not connected to the POST request.
I think that not possible with wordpress since wordpress will route all http request to wp-content using internal functions of via httacess.
I am very new to PHP , but i want to show a html page and handle it with and .php file in codeigniter, How can i do it.
Example could be like this :
http://www.w3schools.com/php/showphp.asp?filename=demo_form_post
I tried to do the same but in controller if i try to run the html file it works fine but as i click on submit and try to fetch values it give my errors.
i do:
1. Made 2 file in view namely: Test.html and Test_Values.php
in Test.html i keep : the code as mentioned in w3 link
and in Test_Value.php I wrote the logic.
2.In controller i calls : $this->load->view("Test.html");
it shows me my html page but as i click on the submit button it says 404 page not found.
Please help me. What am i doing wrong??
Firstly you will have to put your logic in a function in your controller and not a separate .php file. e.g:
class Yourcontrollername extends CI_Controller{
...
function form_processor(){...}
}
Then You are supposed to give the address and the name of the function which is going to process the form you sumbitted in the action attribute of your form! e.g:
<form action="yourControllerName/form_processor" method="post">
Finally, you really need to have to study the Codeigniter Manual
i need to upload a file doc or pdf or rich text through jquery and smarty
i try to pass the file in jquery is given below
window.location.href= sitePath+'download?p='+$('#file').val();
but the p doesn't have value. how to get the file path or name and how can stored in server
in controller i write just pass the query to model is given below
$model=new download();
$id=$model->upload($param);
and i can't develop the model code....
please help me
You can't send files like that.
You should either submit a form with enctype="multipart/form-data" or use some AJAX uploader (which uses form submit to iframe and then stores a file using PHP script).
EDIT: Some references
http://www.w3schools.com/php/php_file_upload.asp - tutorial on how to upload a file using PHP
http://valums.com/ajax-upload/ - example of ajax uploader.
EDIT2: The problem is not with your model code but with the way you try to submit a file.
I Use SQL to store pages of my site & Admin can edit the content of pages
for some pages like enquiry,contact I need to use PHP Forms in Page Content
What I want is page.php?name=contact get data from sql of page name 'contact' which Admin can edit
e.g. Data is:
"Address of Company"
"Use the form below to contact us"
& Below that data I want to include content from contact.php file which include form & all the validation and mail sending function.
Can I use some shortcode or function like wordpress [contact-form] which can be included in sql data so while accessing page.php?name=contact include content from contact.php file below the data of sql.
"Address of Company"
"Use the form below to contact us"
[contact-form]<--- Form from contact.php or enquiry.php included below content
Whats the method to use this type of file include
Thanks
You must do the steps below:
use $name = $_GET['name']; to detect the current page.
Include your PHP file using include($name.'.php');.
Use MySQL functions like mysql_query() to load what is related to your current page and show it in your page. (This should be in contact.php source codes).
Wordpress short-codes are not accessible everywhere ... They work just for Wordpress itself.
i am new to smarty template and i am trying to do this.
I have a html form in the tpl file and in that form action is for a php email function email.php. I am not able to get it to work. if i have the complete code(html form + php email code) and save as a php file, it works fine.
is there any way to call the php code from email.php inside that tpl file? i am completely new and i am just making some changes on the site.
regards
after doing some google search, i found that i can do this way
In the tpl(ex - mail.tpl)
{ php }
//all php code here, in my case its the mailer
{ /php }
and in the form action, just give "mail.tpl" .
fyi, i designed this contact with ajax way to just do the submission in the same page without navigating.
{php}{/php} is deprecated in Smarty V3 now