WP PHP Form Fields are missing. Where are they? - php

This is a hopeful question. I am really, really PHP inexperienced. But I am trying to teach myself a thing or two. The organization I work for uses a WP site. I regularly work on it. I mostly do HTML and CSS (stuff I know about) but I was just digging around in the background and came across something I don't understand at all.
I made a test page here: http://all4ed.org/webinar-event/test-2/
There are two forms on the page. The first ends in a "submit button," the second ends in a "Register Button."
So far so good. I dug around the backend of the WP files, and found the content-webinar.php file and saw that it pulled the form in as an include with:
// The registration form. ?>
<?php if ($registration_required == 'yes'): ?>
<?php include ('assets/includes/webinar/inc-block-registration-form.php'); ?>
<?php endif;
Good, so far.
I went to the "inc-block-registration-form.php" file and here's where it gets weird:
The first form is done with this code:
<form class="webinar-registration" action="<?= $_SERVER["REQUEST_URI"] ?>" method="get">
<div>
<p>
<label for="token">Token</label>
<input type="text" name="token" />
</p>
<p>
<button>Submit</button>
</p>
</div>
</form>
This looks exactly like I thought it would. The second form is written like this:
<form class="webinar-registration" action="<?= $_SERVER["REQUEST_URI"] ?>" method="post">
<div>
<?php if ($webinars->error) : ?>
<p class="error"><?= $webinars->error ?></p>
<?php endif; ?>
<?php foreach ($webinars->form_data as $data) : ?>
<p><?= $webinars->build($data) ?></p>
<?php endforeach; ?>
<p>
<button>Register</button>
<input type="hidden" name="webinars_registration_submitted" value="<?= $post->ID ?>" />
<input type="hidden" name="webinars_registration_title" value="<?= get_the_title() ?>" />
<input type="hidden" name="webinars_registration_url" value="<?= get_permalink() ?>" />
<!-- fields necessary for AA -->
<input type="hidden" name="webinars_user_id" value="<?= get_current_user_id() ?>" />
<input type="hidden" name="webinars_type" value="<?= get_field('webinar_type') ?>" />
<input type="hidden" name="webinars_post_id" value="<?= get_the_ID () ?>" />
</p>
</div>
</form>
Huh???? Where is the "Your Name", "Your E-mmail Address," "Organization," "City, State," or "Question (This is optional)"
How does this work? Where is it pulling those fields from. Any insight would be appreciated. Thanks.

Related

Passing hidden value to a php variable in input tag

I am new to coding and pardon me if it a silly thing I am missing. I have searched through the forum & did not find an answer that suits my need. I have 2 files: jobs.php & jobprocess.php
Jobs.php goes as
<?php session_start();
include('dbConnect.php');
$q1="abc";
$q2="pqr";
$q3="xyz";
$opportunity=29;
echo "Opportunity is". $opportunity;
?>
<html>
<head>
<div align="center">
<form method="post" method="post" action="jobprocess.php">
<input type="text" name="q1" placeholder="<?php echo $q1;?>"><br>
<input type="text" name="q2" placeholder="<?php echo $q2;?>"><br>
<input type="text" name="q3" placeholder="<?php echo $q3;?>"><br>
<input type="hidden" name="opportunity" value="<?php echo $opportunity;?>">
<ul class="actions">
<li><input type="submit" name="submit" value="I would like to join!! "></li>
</ul>
</form>
</div>
</head>
<body>
</body>
</html>
jobprocess.php goes with the code
<?php session_start();
include('dbConnect.php');
$opportunity = $_GET['opportunity'];
echo "opportunity is " . $opportunity;
?>
Unfortunately, the above code is not defining value="29" for opportunity on 2nd page. Thanks in advance
If you echo anything before the html tag it would effectively make the html invalid. Also, the head of the document MUST not have presentational html elements such as forms, divs etc
<?php
session_start();
include('dbConnect.php');
$q1="abc";
$q2="pqr";
$q3="xyz";
$opportunity=29;
?>
<html>
<head>
<title>must have a title</title>
</head>
<body>
<?php
echo "Opportunity is". $opportunity;
?>
<div align="center">
<form method="post" method="post" action="jobprocess.php">
<input type="text" name="q1" placeholder="<?php echo $q1;?>"><br>
<input type="text" name="q2" placeholder="<?php echo $q2;?>"><br>
<input type="text" name="q3" placeholder="<?php echo $q3;?>"><br>
<input type="hidden" name="opportunity" value="<?php echo $opportunity;?>">
<ul class="actions">
<li><input type="submit" name="submit" value="I would like to join!! "></li>
</ul>
</form>
</div>
</body>
</html>
And because the form is set to POST you should probably check and use the POSTed variable rather than a GET variable
<?php
session_start();
include('dbConnect.php');
$opportunity = $_POST['opportunity'];
echo "opportunity is " . $opportunity;
?>
Surprisingly my answer that suggested using session variable instead of hidden form field was deleted?! I guess session variables are illegal now?
The answer was chosen for the best answer even.

PHP echo works on Page A but not on Page B

My goal is to populate a hidden form field with the utm_source from url.
Basically this:
<input id="fieldihhdji" name="cm-f-ihhdji" type="hidden" value="<?php echo $_GET["utm_source"] ?>" />
The problem is this form works perfectly on one page, but not on another.
Working: museumhack.com/test-a/?utm_source=hello (form field is hidden, but populates value)
Not working: museumhack.com/test-b/?utm_source=hello (at the bottom)
It seems like the pages may be processing the double quotes differently, but not clear how to fix. Wordpress required a plugin to process on page PHP -- I installed that and don't think it's the problem.
Here is the entire form that I copy/pasted between pages:
<form action="http://museumhack.createsend.com/t/d/s/ihhykl/" method="post" id="lead-capture">
<p>
<input id="fieldName" name="cm-name" type="text" placeholder="Your Name"/>
</p>
<p>
<input id="fieldEmail" name="cm-ihhykl-ihhykl" type="email" placeholder="you#email.com" required />
</p>
<p>
<input id="fieldjuuilj" name="cm-f-juuilj" type="text" placeholder="(212)555-5555" />
</p>
<p>
<input id="fieldihhdji" name="cm-f-ihhdji" type="hidden" value="<?php echo $_GET["utm_source"] ?>" />
</p>
<p>
<button type="submit">Request Quick Quote</button>
</p>
Thanks,
Try this code , this might help you
<input id="fieldihhdji" name="cm-f-ihhdji" type="hidden" value="<?php echo $_GET['utm_source']='';?>">

Pass variables to another php page using a button

So if someone is logged in my script reads the values and stores it and sets it as variables then I'm trying to make a registration page for something that members can register in.
The script is simple
<div id="english1"><p id="english1p">تأكد من بياناتك ثم اضغط رز الموافقة</p><br>
<form class="register2" action="includes/register2.inc.php" method="post" name="register2form"
<p class="username">اسم المستخدم: <?php echo htmlentities($_SESSION['username']); ?></p>
<p class="email">الايميل: <?php echo htmlentities($_SESSION['email']); ?></p>
<p class="age">السن: <?php echo htmlentities($_SESSION['age']); ?></p>
<p class="coursetype">الكورس المراد التسجيل فيه: <?php echo $coursename; ?></p>
<p class="paymethod">طرق الدفع:</p><ol><li>طريقة</li>
<li>طريقة</li>
<li>طريقة</li>
</ol>
<p class="sure">للتأكيد اضغط تسجيل</p>
<input class="register2button"
type="button"
value="تسجيل"
onclick="" />
</div>
Ignore the letters you don't understand, it's arabic.
So the script reads variables and then I want when the member clicks the submit button, the page POST the variables to includes/register2.inc.php without input as the variables are already set.
How can I do that?
If you want to keep your <p> tags you can store all the variables you want to pass to the next page in <input type="hidden" value="some value" /> These boxes will not be shown on the page, but will pass along data with any request you send to your server.
You can store your value in hidden element and pass it to next page.
<form action="page name" method="post">
<input type="hidden" name="username" value="<?php echo htmlentities($_SESSION['username']); ?>" />
<p class="username"> username : <?php echo htmlentities($_SESSION['username']); ?></p>
<input type="submit" name="submit" value="submit" >
</form>
Inside the form, instead of p you should use input for each parameter:
<input type="text" name="username" value="<?php echo htmlentities($_SESSION['username']); ?>"/>
You can kept this input hidden also like:
<input type="hidden" name="username" value="yourvalue"/>
These input field value won't pass in next page in $_POST if you will use p you have to use input for this.

how to add a remove button to file upload in joomla?

i'm new in coding joomla components i'm coding my first component at all and starting my knowledge from 0 in PHP
in my component i have 4 file uploaders (3 for images/pdf/etc.. and 1 for videos) and i would like to add a button to remove the file in case the person doesn't want the file anymore
can help me in this ?
here's the code of the form page:
<div class="control-group">
<div class="control-label"><?php echo $this->form->getLabel('video'); ?></div>
<div class="controls"><?php echo $this->form->getInput('video'); ?></div>
</div>
<?php if (!empty($this->item->video)) : ?>
[View File]
<?php endif; ?>
<input type="hidden" name="jform[video]" id="jform_video_hidden" value="<?php echo $this->item->video ?>" /> <input type="hidden" name="jform[ordering]" value="<?php echo $this->item->ordering; ?>" />
<input type="hidden" name="jform[state]" value="<?php echo $this->item->state; ?>" />
<input type="hidden" name="jform[checked_out]" value="<?php echo $this->item->checked_out; ?>" />
<input type="hidden" name="jform[checked_out_time]" value="<?php echo $this->item->checked_out_time; ?>" />
Any further information you need ask and i'll provide it
In your controller file, you should add a function called deleteImage that will delete the image from the filesystem. In your layout file (your view's template, as in "default.php"), you should add a link next to each uploaded file that goes like this:
index.php?option=com_pressrelease&task=deleteImage&id=imageId

editing HTML in Joomla pages

I'm no too used to or familiar with the Joomla system. SO I kind of need your help here. Here's my problem.
I'm building a site, but the template came with problems and the template makers refuse to accept they made a mistake. AS Templates Don't buy from these guys unless you don't care about being on your own if something happens.
Anyway, basically, the site's buttons are all out of alignment. I tried fixing them through CSS but no luck. Some things can't be fixed in the CSS files because they belong to the HTML part of it. But as some of you may know, Joomla is PHP not HTML. So my question is how do I fix an HTML line of code in Joomla?
To be specific:
I have this code in my site
<form name="logoutForm" method="post" action="/">
<button class="btl-buttonsubmit"onclick="document.logoutForm.submit();" name="Submit" style="">Log out</button>
<input type="hidden" value="com_users" name="option">
<input type="hidden" value="user.logout" name="task">
<input type="hidden" value="aW5kZXgucGhwP0l0ZW1pZD0xMDE=" name="return">
<input type="hidden" value="1" name="7b6cc3e246acff3e3943410a6f4919cf">
</form>
Since this is not PHP code or CSS I cant find it anywhere
Here are the screenshots of my two trouble areas
and
Thanks again
I'm re-editing this to add the code for the search results. Please review for me, refer to the screenshot as well to see what I see or go to my site and search for anything
<?php
defined('_JEXEC') or die;
$lang = JFactory::getLanguage();
$upper_limit = $lang->getUpperLimitSearchWord();
JHtml::_('bootstrap.tooltip');
?>
<form id="searchForm" action="<?php echo JRoute::_('index.php?option=com_search');?>" method="post">
<div class="btn-toolbar">
<div class="btn-group pull-left">
<input type="text" name="searchword" placeholder="<?php echo JText::_('COM_SEARCH_SEARCH_KEYWORD'); ?>" id="search-searchword" size="30" maxlength="<?php echo $upper_limit; ?>" value="<?php echo $this->escape($this->origkeyword); ?>" class="inputbox" />
</div>
<div class="btn group pull-left">
<button name="Search" onclick="this.form.submit()" class="button btn btn hasTooltip" title="<?php echo JText::_('COM_SEARCH_SEARCH');?>"><span class="icon-search"></span></button>
</div>
<input type="hidden" name="task" value="search" />
<div class="clearfix"></div>
</div>
<div class="searchintro<?php echo $this->params->get('pageclass_sfx'); ?>">
<?php if (!empty($this->searchword)):?>
<p><?php echo JText::plural('COM_SEARCH_SEARCH_KEYWORD_N_RESULTS', '<span class="badge badge-info">'. $this->total. '</span>');?></p>
<?php endif;?>
</div>
<fieldset class="phrases">
<legend><?php echo JText::_('COM_SEARCH_FOR');?>
</legend>
<div class="phrases-box">
<?php echo $this->lists['searchphrase']; ?>
</div>
<div class="ordering-box">
<label for="ordering" class="ordering">
<?php echo JText::_('COM_SEARCH_ORDERING');?>
</label>
<?php echo $this->lists['ordering'];?>
</div>
</fieldset>
<?php if ($this->params->get('search_areas', 1)) : ?>
<fieldset class="only">
<legend><?php echo JText::_('COM_SEARCH_SEARCH_ONLY');?></legend>
<?php foreach ($this->searchareas['search'] as $val => $txt) :
$checked = is_array($this->searchareas['active']) && in_array($val, $this->searchareas['active']) ? 'checked="checked"' : '';
?>
<label for="area-<?php echo $val;?>" class="checkbox">
<input type="checkbox" name="areas[]" value="<?php echo $val;?>" id="area-<?php echo $val;?>" <?php echo $checked;?> >
<?php echo JText::_($txt); ?>
</label>
<?php endforeach; ?>
</fieldset>
<?php endif; ?>
<?php if ($this->total > 0) : ?>
<div class="form-limit">
<label for="limit">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
</label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<p class="counter">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>
</form>
mmm yea I can see what you mean. The template does have some issues. And that is not only your problem there are many places were you need to edit your stylesheet. But it's very hard to eyeball all of them and wrap all the solutions in one answer.
But as an advice you can use firebug if you are using firefox or google developer tools by pressing ctrl shift j to open them. You can edit some of your content live and see the changes that are needed to be done in specific places and then you just do them.
For example I found at the section CONTACT the upper right banner has it title popping out of the template. The fix is located in /templates/as002035/css/tmpl.custom.css line 11 by setting the padding to 0 0 20px.
When Creating an account a modal box splashes into my face. You need to fix that by editing the width and the height of that window again by using those tools.
Finally i cant see the logout button " form " since I can't register to your website due to the mail that was not sent in my e-mails. So probably you need a developer to fix all of these things.
I hope I helped a bit.
Besides the (good) advice already provided, there is a missing answer to your question: where does the HTML markup come from?
You will find it in one of two places: first check your template overrides (which I think is the case looking at your question), which would be located in
/templates/as002035/html/com_users/login/default_logout.php (logout component)
/templates/as002035/html/mod_login/ (login|logout module)
if they are not present, then the default Joomla layouts are in
/components/com_users/views/...
/modules/mod_login/tmpl
Added after clarification below, this is the answer the the comments.
you're missing a class "button" so the line of the module should be:
<input type="submit" value="Log out" class="button btn btn-primary" name="Submit">
instead of
<input type="submit" value="Log out" class="btn btn-primary" name="Submit">
(see the added "button"?). Did you find the template ? is it in the overrides? if you can just make that change you'll get the module fixed. As for the component logout form, http://www.guhlmotors.com/index.php?option=com_users
<button class="button btn" type="submit">Log out</button>
instead of
<button class="button" type="submit">Log out</button>

Categories