Form action duplicates url - forms

new to CI and for some reason the form submits to a wrong url.
the result is : http://localhost/ci/index.php/subjects/localhost/ci/index.php/do_upload
and can't understand why.
This is the html code :
echo form_open_multipart('do_upload');
?>
<input type="file" name="files[]" id="fileupload"
style="position:absolute; top:-200px" multiple />
<input type="submit" id="uploadFile" style="position:absolute; top:-200px" />
<?php echo form_close(); ?>
Any help?
I've also tried to write subjects/do_upload on form open, same thing.

Check your config for base_url and site_url
Leave them '' blank.

Related

problems with classic asp if statment and reading form values

I have been having trouble with a bit of classic asp code
pretty much what I want to do is when a hidden field has a value of 1 a message is displayed
here is the code i have:
<% if (CStr(Request.form("HiddenLog")) = CStr("1")) then %>
<br /> <p style="color:Red;">Message here</p>
<%end if %>
<input type="hidden" id="HiddenLog" value="1" />
The result is nothing appears on screen however if I add an else to the if statment like so
<% if (CStr(Request.form("HiddenLog")) = CStr("1")) then %>
<br /> <p style="color:Red;">Message here</p>
<%else%>
<br /> <p style="color:Red;">Message here</p>
<%end if %>
The message always appears (of course this was to prove that the if statment is working and that the problem most likly is with getting the form values), can someone please tell me what it is I have done wrong
Thanks
Edit A couple of people have asked about my form so I will post that here as well
<form id="form1" method="post">
all the controls are contained inside this form
you have to give the input field a name attribute. you only have an id attribute this is not posted so just use
<input type="hidden" id="HiddenLog" name="HiddenLog" value="1" />

if isset doesn't work in php

I'm having a form with only one submit button. I don't know why, but when I use this code and I click on the submit button, nothing is happening. If I use a ! before the isset you'll see the echo in the page. I don't know what's wrong with it.
<form>
<input type="submit" value="Toevoegen" name="addImg" />
</form>
<?
if (isset($_POST['addImg'])) {echo "haaallloooo";}
?>
Maybe, form by default is sending variables by get, try using method="POST" attribute in form tag
You have to set the method to POST.
Otherwise you can use:
$_REQUEST['addImg']
The variable $_REQUEST can access both GET and POST parameters.
Form needs an action and a method.
<form action="" method="post">
<input type="submit" value="Toevoegen" name="addImg" />
</form>
<?
if (isset($_POST['addImg'])) {echo "haaallloooo";}
?>
Regarding "isset", if $_POST['addImg'] is not set, it doesn't echo "haaallloooo".
isset — Determine if a variable is set and is not NULL
Check http://hk.php.net/manual/en/function.isset.php

Drupal 7: Have an Edit Field within a Viewed Node

I have a content type which is only viewable (not editable) to a certain role. I've customised the form output completely (manually outputting each field as they display in a certain way).
However there's one field I would like this user to be able to 'edit' which is a custom 'revision comment' field I've made. I can hardcode in the form fields, except of course it won't work without the token, build id etc that Drupal generates like this:
<input type="hidden" name="form_build_id" value="<?php print render($form['#build_id']); ?>">
<input type="hidden" name="form_token" value="<?php print drupal_get_token($form['#token']); ?>">
<input type="hidden" name="form_id" value="<?php print render($form['#form_id']); ?>">
So essentially I'm wondering what workaround I could use, as $form and it's variable are obviously only generated when 'editing' the node.
In case anyone else needs to know, I hardcoded this into the template file and it works:
<form class="node-form node-project-form" action="/dashboard" method="post" id="project-node-form" accept-charset="UTF-8">
<input type="hidden" name="nid" value="<?php print $nodeid; ?>">
<input type="hidden" name="uid" value="<?php print $user->uid; ?>">
<div id="revision-comments" style="margin:0">
<label for="log-comments">Log Message</label>
<textarea id="log-comments" name="log_comments"" cols="60" rows="4" class="form-textarea"></textarea>
</div>
<input type="submit" id="edit-submit" name="op" value="Post Comment" class="form-submit">
</form>

Symfony: form field access with no sfForm object

i'm working on a symfony project and i developed a form to upload a file and save its info to a table in my model. And didn't use the sfForm class to implement my form.
Here you have my form
<form name="new_file" action="<?php echo url_for('home/uploadFile');?>" method="post">
<input type="file" id="file">
<input value="<?php echo $codigo_maestro?>" id="master_id">
<input value="<?php echo $codigo_entidad?>" id="entity_id">
<input type="submit" value="Upload">
</form>
So now i'm trying to access the fields of the sumbited form in my action function and don't know how :(
$request->getParameter('file');
$request->getParameter('master_id');
$request->getParameter('entity_id');
this code didn't work.
So please help me solve this! How can i access the fields of my form from the action??
You need to add a name to your form fields, that's the name you can access them via $request->getParameter().
finally i did this way, maybe not most elegant, but working
in action.class.php
$file= $_FILES['file'];
$filesize = $archivo['size'];
$filetype = $archivo['type'];
$filename = str_replace(' ','-',$file['name']);

Zend controller/view newbie puzzle: $_GET & $_POST empty - on receipt from HTML form within view

Zend newbie here ... And just to make it better, my mission is to build on top of someone else's pre-existing Zend site.
(BTW: zf show version --> Zend Framework Version: 1.11.1 -- I seem to have Zend_Form).
Here's the curious bit. All the forms are built in HTML within views. They seem to work, although I can't figure out how -- especially given what I am seeing.
I followed the convention and created a view for a test form and wrote the form:
<form action="<?php echo $this->url(array('controller'=>'ControllerName','action'=>'submit'));?>" method="post" style="margin-left:20px">
<p class="bold setmgr">Your email here:</p>
<div class="field">
<input class="text" type="text name="custEmail"/>
</div>
<div class="field">
<input class="button" value="Submit and be free!" type="submit"/>
</div>
</form>
The submitAction member in the controller is firing correctly. No problem.
But ALL the places I could look for the POST data appear to be empty!
echo "obj custEmail = [" . $this->_request->getPost('custEmail') . "]\n";
echo "GET custEmail = [" . $_GET['custEmail'] . "]\n";
echo "POST custEmail = [" . $_POST['custEmail'] . "]\n";
if ($this->_request->isPost()) {
$data = $this->_request->getPost();
Zend_Debug::dump($data);
}
They all produce nothing.
I'd be much obliged for a solution or even a clue about what is going wrong.
Thanks for reading.
Your form is not in the correct format.As it's PHP you can use form like this or you can even generate a ZEND_FORM(which is profound way to do it).It's always a good practise to work around with ZEND_FORM.If you still want to use this and the go by your way,here is th snippet I modified for you.
I am modifying the Code for you.Your View should have this form in it;
<form action="" method="post" style="margin-left:20px">
<p class="bold setmgr">Your email here:</p>
<div class="field">
<input class="text" type="text" name="custEmail"/>
</div>
<div class="field">
<input class="button" value="Submit and be free!" type="submit" name="submit"/>
</div>
</form>
<?php
echo $this->custEmail;
?>
Now write the following one on your ACTIOn,i.e. submitAction;
public function submitAction()
{
if ($this->getRequest()->isPost())
{
$custEmail = $this->getRequest()->getPost('custEmail');
echo $custEmail;
$this->view->custEmail = $custEmail;
}
}
Now check if it works for you or not.
Create a form using Zend_Form. When ZF already has a way to create forms, you should use that. Your method is like a hack and is not a recommended way to do things.
Check here on how to create a Zend_Form
http://framework.zend.com/manual/en/zend.form.html