Self-calling forms
First unread post • 2 posts
• Page 1 of 1
Self-calling forms
I'm a bit confused about how to do this. We have created a petition form on our live site - http://vvfh.org/petition/ProcessForm.php
It works fine. I'm working on migrating the site to a different hosting situation, and I decided to use Joomla as the CMS. (Previously all my sites were hand built using vi.)
I tried to port this application over using Jumi, but it doesn't work. Here's the page: http://yyy.specialforcesphotos.com/home ... ction.html
Looks fine but when you click on Submit you get a 404. I found this page: http://2glux.com/projects/jumi/tutorial ... s-tutorial. I think it points to the problem. The form needs to be self calling. But, when I tried to adapt it, I failed. (I'm not a programmer. I'm a retired computer security guy who can fumble his way around in code and use Google a lot.
But I'm not sure how to incorporate it into the existing framework. Here's the current index.php file:
Here's the existing ShowForm.php file:
I tried stealing the code in the tutorial and adapting the ShowForm.php page, but when I did that, the form no longer appears in the page.
Should I be wrapping the index.php page in this code instead?
It works fine. I'm working on migrating the site to a different hosting situation, and I decided to use Joomla as the CMS. (Previously all my sites were hand built using vi.)
I tried to port this application over using Jumi, but it doesn't work. Here's the page: http://yyy.specialforcesphotos.com/home ... ction.html
Looks fine but when you click on Submit you get a 404. I found this page: http://2glux.com/projects/jumi/tutorial ... s-tutorial. I think it points to the problem. The form needs to be self calling. But, when I tried to adapt it, I failed. (I'm not a programmer. I'm a retired computer security guy who can fumble his way around in code and use Google a lot.
But I'm not sure how to incorporate it into the existing framework. Here's the current index.php file:
- Code: Select all
<?php
date_default_timezone_set('UTC');
#phpinfo();
require_once "DB.php";
include "ShowBanner.php";
include "ShowSocialMedia.php";
echo '<table>';
echo '<tr>';
echo '<td style="vertical-align:top; padding:1px; width:700px;">';
include "ShowPetition.php";
echo '</td>';
echo '<td style="vertical-align:top;">';
include "ShowForm.php";
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td style="vertical-align:top;">';
include "ShowReasons.php";
echo '</td>';
echo '<td style="vertical-align:top;">';
include "ShowRecent.php";
echo '<br>';
include "ShowDonations.php";
echo '</td>';
echo '</tr>';
echo '</table>';
include "ShowFooter.php";
?>
Here's the existing ShowForm.php file:
- Code: Select all
<form method="post" action="ProcessForm.php">
<p><input type="text" name="firstname" id="firstname" placeholder="*First Name" required /></p>
<p><input type="text" name="lastname" id="lastname" placeholder="*Last Name" required /></p>
<p><input type="email" name="email" id="email" placeholder="*Email Address" required /></p>
<?php include "ShowCountries.php";?>
<p><input type="text" name="zipcode" id="zipcode" value="" maxlength="10" placeholder="Zip Code"></p>
<p><textarea id="service" name="service" rows="3" maxlength="500" placeholder="If you are a Vietnam Vet, please list your unit(s) and years of assignment."></textarea></p>
<p><textarea id="reason" name="reason" rows="3" maxlength="500" placeholder="Why is this petition important to you?"></textarea></p>
<p><input type="submit" value="SIGN"/></p>
<?php echo '<p><label>'.$GLOBALS['ErrorMsg'].'</lable></p>'?>
<div id="Agreement">
By signing, you agree to our <a href="http://www.vvfh.org/tos.html" target="_blank">terms of service</a> and <a href="http://www.vvfh.org/privacy.html" target="_blank">privacy policy</a>.
</div>
<br>
</form>
I tried stealing the code in the tutorial and adapting the ShowForm.php page, but when I did that, the form no longer appears in the page.
- Code: Select all
<?php
function self_form()
{
$anchor = "myform"; //the $anchor variable we will need later
echo "<a name = $anchor></a>"; //the html anchor we will need later
echo '<td style="vertical-align:top; width="500;">';
if(!isSet($_POST['email'])) //if there is no email address then write the form
{
$return_url = get_return_url($anchor);
?>
<form method="post" action="ProcessForm.php">
<p><input type="text" name="firstname" id="firstname" placeholder="*First Name" required /></p>
<p><input type="text" name="lastname" id="lastname" placeholder="*Last Name" required /></p>
<p><input type="email" name="email" id="email" placeholder="*Email Address" required /></p>
<?php include "ShowCountries.php";?>
<p><input type="text" name="zipcode" id="zipcode" value="" maxlength="10" placeholder="Zip Code"></p>
<p><textarea id="service" name="service" rows="3" maxlength="500" placeholder="If you are a Vietnam Vet, please list your unit(s) and years of assignment."></textarea></p>
<p><textarea id="reason" name="reason" rows="3" maxlength="500" placeholder="Why is this petition important to you?"></textarea></p>
<p><input type="submit" value="SIGN"/></p>
<?php echo '<p><label>'.$GLOBALS['ErrorMsg'].'</lable></p>'?>
<div id="Agreement">
By signing, you agree to our <a href="http://www.vvfh.org/tos.html" target="_blank">terms of service</a> and <a href="http://www.vvfh.org/privacy.html" target="_blank">privacy policy</a>.
</div>
<br>
</form>
<?php
}
else //if there is an email thank the signer and write the email into the database
{
echo "<b>Thank you for your signing out petition.</b>";
write_data($_POST['email']);
echo "</td>";
}
}
function get_return_url($anchor)
{
if ($query_string = mosGetParam( $_SERVER, 'QUERY_STRING', '' ))
{
$return = 'index.php?' . $query_string;
}
else
{
$return = 'index.php';
// an url starts with index.php now
// converting & to & for xtml compliance
$return = str_replace( '&', '&', $return );
//adding anchor to the end of url
$return .="#$anchor"; //adding anchor to url
//prepand http:// to the beginning of the url
return sefRelToAbs($return);
}
?>
}
Should I be wrapping the index.php page in this code instead?
Last edited by pschmehl on Mon Jul 13, 2015 6:55 am, edited 1 time in total.
Paul Schmehl
Independent Researcher
Independent Researcher
- pschmehl
- Posts: 3
- Joined: Mon Jul 13, 2015 2:19 am
Re: Sell-calling forms
I tried putting the entire "wrapper" code in the index.php file, but the form still does not print on the page.
- Code: Select all
<?php
# Incorporate Joomla code to use mosGetParam
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
# Hardy's original code
date_default_timezone_set('UTC');
#phpinfo();
require_once "DB.php";
include "ShowBanner.php";
include "ShowSocialMedia.php";
echo '<table>';
echo '<tr>';
echo '<td style="vertical-align:top; padding:1px; width:700px;">';
include "ShowPetition.php";
echo '</td>';
echo '<td style="vertical-align:top;">';
function self_form()
{
$anchor = "myform"; //the $anchor variable we will need later
echo "<a name = $anchor></a>"; //the html anchor we will need later
echo '<td style="vertical-align:top; width="500;">';
if(!isSet($_POST['email'])) //if there is no email address then write the form
{
$return_url = get_return_url($anchor);
echo '<form method="post" action="ProcessForm.php">';
echo '<p><input type="text" name="firstname" id="firstname" placeholder="*First Name" required /></p>';
echo '<p><input type="text" name="lastname" id="lastname" placeholder="*Last Name" required /></p>';
echo '<p><input type="email" name="email" id="email" placeholder="*Email Address" required /></p>';
include "ShowCountries.php";
echo '<p><input type="text" name="zipcode" id="zipcode" value="" maxlength="10" placeholder="Zip Code"></p>';
echo '<p><textarea id="service" name="service" rows="3" maxlength="500" placeholder="If you are a Vietnam Vet, please list your unit(s) and years of assignment."></textarea></p>';
echo '<p><textarea id="reason" name="reason" rows="3" maxlength="500" placeholder="Why is this petition important to you?"></textarea></p>';
echo '<p><input type="submit" value="SIGN"/></p>';
echo '<p><label>'.$GLOBALS['ErrorMsg'].'</lable></p>';
echo '<div id="Agreement">';
echo 'By signing, you agree to our <a href="http://www.vvfh.org/tos.html" target="_blank">terms of service</a> and <a href="http://www.vvfh.org/privacy.html" target="_blank">privacy policy</a>.';
echo '</div>';
echo '<br>';
echo '</form>';
}
else //if there is an email thank the signer and write the email into the database
{
echo "<b>Thank you for your signing out petition.</b>";
write_data($_POST['email']);
echo "</td>";
}
}
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td style="vertical-align:top;">';
include "ShowReasons.php";
echo '</td>';
echo '<td style="vertical-align:top;">';
include "ShowRecent.php";
echo '<br>';
include "ShowDonations.php";
echo '</td>';
echo '</tr>';
echo '</table>';
include "ShowFooter.php";
function get_return_url($anchor)
{
if ($query_string = mosGetParam( $_SERVER, 'QUERY_STRING', '' ))
{
$return = 'index.php?' . $query_string;
}
else
{
$return = 'index.php';
}
// an url starts with index.php now
// converting & to & for xtml compliance
$return = str_replace( '&', '&', $return );
//adding anchor to the end of url
$return .="#$anchor"; //adding anchor to url
//prepand http:// to the beginning of the url
return sefRelToAbs($return);
}
?>
Paul Schmehl
Independent Researcher
Independent Researcher
- pschmehl
- Posts: 3
- Joined: Mon Jul 13, 2015 2:19 am
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: Bing [Bot] and 1 guest