php conditional statement not working in magento - php

So I have an e-newsletter popup on my website so users can stay in contact and up to date with our happenings. I only want the popup to appear on the homepage and i've put together a simple shorthand conditional statement like so:
<?php if(Mage::getSingleton('cms/page')->getPageId() == '2' && Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms') : ?>
<div id="newsletter_sign_up" style="display:none;" >
<div style="padding:20px;" >
<form action="<?php echo($this->getUrl('newsletter/subscriber/new')) ?>" method="post" >
<div class="fieldset">
<h1 style="color: #28ced7; text-align: left; font-family: Arial, Helvetica, sans-serif; font-size: 28px;">verbiage goes here</h1>
<h2 class="legend" style="text-align:left; font-family: Arial, Helvetica, sans-serif; font-size: 13px;">verbiage goes here</h2>
<!--end-->
<ul class="form-list">
<li class="fields">
<div class="customer-name">
<div class="field name-firstname">
<label class="required" for="firstname" style="text-align:left;"><em>*</em>First Name</label>
<div class="input-box">
<input type="text" class="input-text required-entry" maxlength="255" title="First Name" value="" name="firstname" id="firstname" autocomplete="off"/>
</div>
</div>
<div class="field name-lastname">
<label class="required" for="lastname" style="text-align:left;"><em>*</em>Last Name</label>
<div class="input-box">
<input type="text" class="input-text required-entry" maxlength="255" title="Last Name" value="" name="lastname" id="lastname" autocomplete="off"/>
</div>
</div>
</div>
</li>
<li>
<label class="required" for="email_address" style="text-align:left;"><em>*</em>Email Address</label>
<div class="input-box">
<input type="text" class="input-text validate-email required-entry" title="Email Address" value="" id="email_address" name="email" autocomplete="off"/>
<input class="pop_newsletter_source" name="source" type="hidden" value="3" />
</div>
</li>
</ul>
</div>
<div class="buttons-set form-buttons">
<button onclick="pop_newsletter.submit(); return false;" title="Submit" class="button" type="submit" autocomplete="off" style="position: relative; right: 140px;"><span><span>Submit</span></span></button>
</div>
<p class="required">* Required Fields</p>
<h2 style="text-align: left; font-size: 10px;">Email Privacy Statement:</h2>
<p style="font-family: Arial, Helvetica, sans-serif; font-size: 10px; text-align: left;">more verbiage</p>
<!--//end-->
</form>
</div>
</div>
<?php endif; ?>
I've checked to verify that the page id is 2.
<?php echo "<pre>"; print_r(Mage::getSingleton('cms/page')->getPageId()); echo "</pre>"; ?>
I can't figure out why it breaks... am i missing something blatantly obvious? Any help would be appreciated.

Related

Saving data that depends on a selected field

I want to save data depending on the option selected on the select menu, its option has a certain percentage attached to it, i tried using the code below but its only saving one value irregardless of which option is selected.
I have tried to use conditional-field by Steven Wanderski, but its only saving one value in all selections
my index.php
<?php
require_once('config.php');
require_once('function.php');
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
<script src="js/conditional-field.min.js"></script>
</head>
<body>
<div class="container mt-3">
<form role="form" method="post" action="process.php">
<?php $grant="20";
$direct_cost="100";
$discounts="100";
$overhead_costs="70";
?>
<p class="h4 mb-4">Supplier Spends</p>
<div class="form-row mb-4">
<div class="col">
<label for="prog_description">Name of the Programme:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="prog_description" name="prog_description" class="form-control" placeholder="enter name of the programme embarked on" required>
</div>
</div>
<label for="type_of_contrib">Type of Contribution:</label><span style="color: red !important; display: inl`enter code here`ine; float: none;">*</span>
<select name="type_of_contrib" id="TypeOfContribution" class="TypeOfContribution form-control mb-4" required>
<option value="">--select type of contribution--</option>
<option value="Grant Contribution">Grant Contribution</option>
<option value="Direct cost incurred">Direct cost incurred</option>
<option value="discounts"> Discounts</option>
<option value="Overheads costs">Overheads costs</option>
<option value="Standard Loan">Standard Loan</option>
<option value="Lower Interest Rate">Lower Interest Rate</option>
<option value="Guarantees Provided">Guarantees Provided</option>
<option value="Minority Investment">Minority Investment</option>
<option value="Services at no Cost">Services at no Cost</option>
<option value="Services at a Discount">Services at a Discount</option>
<option value="Time of Employees">Time of Employees</option>
<option value="Shorter payment periods">Shorter payment periods</option>
<option value="Investment with lower Dividend">Investment with lower Dividend</option>
</select>
<div class="benefit form-row mb-4 ">
<div class="col">
<label for="Grant Contribution">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="<?php echo $grant;?>" readonly="readonly" required>
</div>
</div>
<div class="benefit2 form-row mb-4">
<div class="col">
<label for="Direct cost incurred">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="<?php echo $direct_cost;?>" readonly="readonly" required>
</div>
</div>
<div class="benefit3 form-row mb-4">
<div class="col">
<label for="Discounts">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor"class="form-control" placeholder="benefit factor" value="<?php echo $discounts;?>" readonly="readonly" required>
</div>
</div>
<div class="benefit4 form-row mb-4">
<div class="col">
<label for="Overheads costs">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor"class="form-control" placeholder="benefit factor" value="<?php echo $overhead_costs;?>" readonly="readonly" required>
</div>
</div>
<div class="benefit5 form-row mb-4">
<div class="col">
<label for="Standard Loan">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor"class="form-control" placeholder="benefit factor" value="70" readonly="readonly" required>
</div>
</div>
<div class="benefit6 form-row mb-4">
<div class="col">
<label for="Lower Interest Rate">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor"class="form-control" placeholder="benefit factor" value="50" readonly="readonly" required>
</div>
</div>
<div class="benefit7 form-row mb-4">
<div class="col">
<label for="Guarantees Provided">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="3" readonly="readonly" required>
</div>
</div>
<div class="benefit8 form-row mb-4">
<div class="col">
<label for="Minority Investment">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor"class="form-control" placeholder="benefit factor" value="70" readonly="readonly" required>
</div>
</div>
<div class="benefit9 form-row mb-4">
<div class="col">
<label for="Services at no Cost">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="60" readonly="readonly" required>
</div>
</div>
<div class="benefit10 form-row mb-4">
<div class="col">
<label for="Services at a Discount">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="60" readonly="readonly" required>
</div>
</div>
<div class="benefit11 form-row mb-4">
<div class="col">
<label for="Time of Employees">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="60" readonly="readonly" required>
</div>
</div>
<div class="benefit12 form-row mb-4" value="100";>
<div class="col">
<label for="shorter payment periods">Benefit Factor:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="text" id="benefit_factor" name="benefit_factor" class="form-control" placeholder="benefit factor" value="15" readonly="readonly" required>
</div>
</div>
<label for="budgeted_spend">Budgeted Spend:</label>
<input type="number" id="budgeted_spend" name="budgeted_spend" class="form-control mb-4" placeholder="Budgeted Spend" required>
<label for="actual_amount">Actual Amount Spent:</label><span style="color: red !important; display: inline; float: none;">*</span>
<input type="number" id="actual_amount" name="actual_amount" class="form-control mb-4" placeholder="Actual Amount Spent" required>
<label for="current_status">Status of the programme:</label><span style="color: red !important; display: inline; float: none;">*</span>
<select name="current_status" id="current_status" class="status form-control mb-4" required>
<option disabled selected>--select current status--</option>
<option value="started">started</option>
<option value="in_progress">in-progress</option>
<option value="completed">completed</option>
<option value="cancelled">cancelled</option>
</select>
<label for="anticipated_completion">Anticipated Completion Date:</label>
<input type="date" id="anticipated_completion" name="anticipated_completion" class="form-control mb-4" required>
<button class="btn btn-info my-4 btn-block" type="submit">Save Data</button>
</form>
<br>
<?php
get_all_records();
?>
</div>
<script>
$(document).ready(function(){
new ConditionalField({
control: '.TypeOfContribution',
visibility: {
'Grant Contribution': '.benefit',
'Direct cost incurred': '.benefit2',
'discounts': '.benefit3',
'Overheads costs': '.benefit4',
'Standard Loan': '.benefit5',
'Lower Interest Rate': '.benefit6',
'Guarantees Provided': '.benefit7',
'Minority Investment': '.benefit8',
'Services at no Cost': '.benefit9',
'Services at a Discount': '.benefit10',
'Time of Employees': '.benefit11',
'Shorter payment periods': '.benefit12',
}
});
});
</script>
?>

Move two input boxes side by side

I'm trying to re-arrange my input boxes to look something like this:
currently, they just go down one under each other
I tried using this code but all it did was make the boxes shorter
http://jsfiddle.net/aY9HC/
Here is my code
<style>
.fieldBlock
{
display: block;
width: 200px;
float: left;
}
</style>
here is the text box code
<div id="main-wrapper">
<div class="unix-login">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-lg-4">
<div class="login-content card">
<center><h3>Register Account</h3>
<p><strong>Create Account</strong> » Purchase » Begin</p></center>
<div class="login-form">
<form data-toggle="validator" method="post" id="register_form">
<div class="form-group">
<div class="fieldBlock">
<label>Name</label>
<input id="username" type="name" name="name" class="form-control" placeholder="First & Last Name" required>
</div>
</div>
<div class="form-group">
<div class="fieldBlock">
<label>Age</label>
<input type="dob" id="age" name="age"class="form-control" placeholder="03/26/2001" required></div>
</div>
<div class="form-group">
<label>Email address</label>
<input id="email" type="email" name="email" class="form-control" placeholder="Email" data-error="This email is invalid" required>
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
<label>Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Password" data-minlength="8" data-error="Minimum of 8 characters" required>
<div class="help-block"></div>
</div>
<div class="form-group">
<label>Choose Your Course</label>
<select name="course" class="form-control">
<option value="0" selected>Texas Parent Taught Drivers Ed</option>
<option value="1">Texas Instructor Taught Drivers Ed</option>
<option value="2">Texas Adult Drivers Ed</option>
</select>
</div>
<div class="form-group">
<label>Referral</label>
<input id="referral" type="text" name="referral" class="form-control" placeholder="Referral Code" value="<?php echo $refer?>">
</div>
<div class="form-group checkbox">
<label>
<input id="policy" type="checkbox" data-error="Don't you agree?" required> Agree the terms and Privacy Policy
</label>
<div class="help-block with-errors"></div>
</div>
<button name="register" type="submit" class="btn btn-primary btn-flat m-b-30 m-t-30" >Register</button>
<div class="register-link m-t-15 text-center">
<p>Already have account? Sign in</p>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
All it did was keep the boxes under each other and make them a bit smaller. I'm a bit stuck right now. Help would be appericated. Thanks!
try adding
display:inline-block
on both text boxes.
Alternatively you can also try
display: flex;
You were on the right track with using float to move the elements next to each other. However, when elements are floating next to each other in a cramped space they will stack up by default. By making the parent container larger or smaller you can see how this works.
Also, there were a couple of missing fieldBlocks so the styles stop being applied.
I didn't want to take too much time on it but thought it would be fun to throw together a working sample from the code you provided. There's probably much more that could be cleaned up but hopefully it provides some insight.
http://jsfiddle.net/aY9HC/1373/
CSS
/* make a nice form wrapper */
#main-wrapper{
width:100%;
padding:1em;
}
#main-wrapper h3,
#main-wrapper p,
#main-wrapper button{
text-align:center;
margin-bottom:10px;
clear:left;
}
#main-wrapper button{
display:block;
position:relative;
left:45%;
}
/* Define our basic fieldBlock style / stagger rows */
.fieldBlock
{
width: 50%;
float: left;
margin-bottom:15px;
}
.fieldBlock input,
.fieldBlock select{
height:30px;
}
.fieldBlock input[type='checkbox']{
height:10px;
}
.fieldBlock:nth-of-type(3n){
width:100%;
}
.fieldBlock:nth-of-type(3n) input{
width:40%;
}
/* Define look for our labels */
.fieldBlock label{
font-weight:bold;
display:block;
margin-bottom:5px;
}
.fieldBlock .nonblock{
display:inline-block;
}
HTML
<div id="main-wrapper">
<h3>Register Account</h3>
<p><strong>Create Account</strong> » Purchase » Begin</p>
<form data-toggle="validator" method="post" id="register_form">
<div class="fieldBlock">
<label>Name</label>
<input id="username" type="name" name="name" class="form-control" placeholder="First & Last Name" required>
</div>
<div class="fieldBlock">
<label>Age</label>
<input type="dob" id="age" name="age"class="form-control" placeholder="03/26/2001" required>
</div>
<div class="fieldBlock">
<label>Email address</label>
<input id="email" type="email" name="email" class="form-control" placeholder="Email" data-error="This email is invalid" required>
<div class="help-block with-errors"></div>
</div>
<div class="fieldBlock">
<label>Password</label>
<input id="password" type="password" name="password" class="form-control" placeholder="Password" data-minlength="8" data-error="Minimum of 8 characters" required>
<div class="help-block"></div>
</div>
<div class="fieldBlock">
<label>Choose Your Course</label>
<select name="course" class="form-control">
<option value="0" selected>Texas Parent Taught Drivers Ed</option>
<option value="1">Texas Instructor Taught Drivers Ed</option>
<option value="2">Texas Adult Drivers Ed</option>
</select>
</div>
<div class="fieldBlock">
<label>Referral</label>
<input id="referral" type="text" name="referral" class="form-control" placeholder="Referral Code" value="<?php echo $refer?>">
</div>
<div class="fieldBlock checkbox">
<input id="policy" type="checkbox" data-error="Don't you agree?" required />
<label for="policy" class="nonblock">Agree the terms and Privacy Policy</label>
<div class="help-block with-errors"></div>
</div>
<button name="register" type="submit" class="btn btn-primary btn-flat m-b-30 m-t-30" >Register</button>
<p>Already have account? Sign in</p>
</form>
</div>
You can just use col classes
<div class='row'>
<div class='col'>Your first text box</div>
<div class='col'>Your second text box</div>
</div>
Try to use bootstrap grid (rows and cols) to organize input fields.
Example pattern:
<form data-toggle="validator" method="post" id="register_form">
<div class="row mx-0">
<div class="form-group col-6">
<div class="fieldBlock">
<label>Name</label>
<input id="username" type="name" name="name"
class="form-control"
placeholder="First & Last Name" required>
</div>
</div>
<div class="form-group col-6">
<div class="fieldBlock6">
<label>Age</label>
<input type="dob" id="age"
name="age"class="form-control"
placeholder="03/26/2001" required>
</div>
</div>
</div>
<div class="row mx-0">
<div class="form-group col-12">
<label>Email address</label>
<input id="email" type="email" name="email"
class="form-control" placeholder="Email"
data-error="This email is invalid" required>
<div class="help-block with-errors"></div>
</div>
</div>
</form

Place error message inside a Bootstrap input

I have a PHP that validates if a input is empty if it is an error message is displayed e.g Email required, I am using Bootstrap for my form. Originally the message is displayed under the input (which I don't want).
Code im currently using:
<label>Number Of Rooms: </label>
<input type="number" class="form-control input-sm" max="10" name="Rooms" value="<?php echo $RoomErr;?>">
<span class="error">* <br><?php echo $RoomErr;?></span>
here is the link to the website website
I want to display the error message inside the text input i tried assigning the error to the value of the input:
<label>Number Of Rooms: </label>
<input type="number" class="form-control input-sm error" max="10" name="Rooms" value="<?php echo $RoomErr;?>">
The following does not work.
My CSS just assigns the error to color red
.error{
color:red;
}
I can't find much stuff about this.
You can try like this, because it is working as a placeholder.
<input type="number" class="form-control input-sm error" max="10" name="Rooms" placeholder="<?php echo $RoomErr;?>">
Please try this. I am using position:absolute; And manage this
label {
display: inline-block;
margin-left: 20px;
width: 135px;
}
.error {
color: red;
}
.form-group .error {
left: 165px;
position: absolute;
top: 5px;
}
.form-group{position:relative;}
.form-inline .form-control{display: inline-block;
vertical-align: middle;
width: auto;}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<div class="col-md-9">
<div class="container-form">
<p><span class="error">* required field.</span></p>
<form id="EmailForm" class="form-horizontal" action="" method="post">
<div class="form-inline">
<div class="form-group" style="position: relative;">
<label for="first_name">Name: </label>
<input class="form-control input-sm" name="first_name" type="text">
<span class="error">*Name is required</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label for="last_name">SurnameName: </label>
<input class="form-control input-sm" name="last_name" type="text">
<span class="error">*</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label for="email">Email: </label>
<input class="form-control input-sm" name="email" type="text">
<span class="error">* Email is required</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label>Number Of Rooms: </label>
<input class="form-control input-sm" max="10" name="Rooms" value="Mininum number of Hours : 3" type="number">
<span class="error">* Mininum number of Hours : 3</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label> Number hours: </label>
<input class="form-control input-sm" min="3" name="Hours" type="number">
<span class="error">* Mininum number of Hours : 3</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label for="description">Description of the House: </label>
<textarea name="description" rows="auto" class="form-control input-sm" cols="55"></textarea>
<span class="error">* Description is required</span>
</div>
</div>
<div class="form-inline">
<div class="form-group">
<div class="radio" style="margin-left:70px">
<input name="ironing" id="radiobtn" value="Yes" type="radio">
Yes
</div>
<div class="radio">
<input name="ironing" id="radiobtn" value="No" type="radio">
No
</div>
<span class="error">* Ironing is Required</span>
<span class="help-block" style="margin-left:50px">Would Like Ironing?</span>
</div>
</div>
<input class="btn btn-info btn-lg" name="submit" value="Submit" type="submit">
</form>
</div>
</div>

Why isn't my submit button working on a magento CMS page?

all I'm having some issue with a custom form on a magento CMS page, the form is as follows:
<div class="comp-container">
<div class="row" style="text-align: center;">
<p class="comp-title">HOW TO ENTER</p>
<div class="col-md-12">
<div class="col-md-3"> </div>
<div class="col-md-6">
<p>For your chance to win £100 to spend on our website, enter your name and email address below.If you win, you’ll be notified by email – good luck!</p>
</div>
<div class="col-md-3"> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-3"> </div>
<div class="col-md-6"><form id="competition" action="{{store url='/comp/checker.php'}}" method="post" name="competition"><span class="input-title">First Name:</span><input id="fname" class="form-control" type="text" name="fname" /> <br /> <span class="input-title">Last Name:</span> <input id="lname" class="form-control" type="text" name="lname" /><br /> <span class="input-title"> Email address: </span><input id="email" class="form-control" type="email" name="email" />**</form>**</div>
<div class="col-md-3"> </div>
</div>
</div>
<p> </p>
<div class="row" style="text-align: center;">
<div class="col-md-12">
<div class="col-md-3"> </div>
<div class="col-md-6">
<p class="comp-title">BOOST YOUR CHANCE OF WINNING!</p>
<p>Recommend a friend by entering their details as well and your name will be entered into the draw twice. Want to recommend someone? <input id="comp-checkbox1" type="checkbox" name="comp-checkbox1" /></p>
</div>
<div class="col-md-3"> </div>
</div>
</div>
<div class="row">
<div class="col-md-12 friend" style="padding-top: 20px;">
<p class="input-title" style="text-align: left; padding-left: 20px;">Your Friends Email</p>
<div class="col-md-3"><input id="fr_name" class="form-control" type="text" name="fr_name" /></div>
<div class="col-md-3"><input id="fr_lname" class="form-control" type="text" name="fr_lname" /></div>
<div class="col-md-6"><input id="fr_email" class="form-control" type="email" name="fr_email" /></div>
<p>Recommend another friend ? - <input id="comp-checkbox2" type="checkbox" name="comp-checkbox2" /></p>
</div>
</div>
<div class="row">
<div class="col-md-12 friend2" style="padding-top: 20px;">
<p class="input-title" style="text-align: left; padding-left: 20px;">Your Friends Email</p>
<div class="col-md-3"><input id="fr_name2" class="form-control" type="text" name="fr_name2" /></div>
<div class="col-md-3"><input id="fr_lname2" class="form-control" type="text" name="fr_lname2" /></div>
<div class="col-md-6"><input id="fr_email2" class="form-control" type="email" name="fr_email2" /></div>
<p>Recommend another friend ? - <input id="comp-checkbox3" type="checkbox" name="comp-checkbox3" /></p>
</div>
</div>
<div class="row">
<div class="col-md-12 friend3" style="padding-top: 20px;">
<p class="input-title" style="text-align: left; padding-left: 20px;">Your Friends Email</p>
<div class="col-md-3"><input id="fr_name3" class="form-control" type="text" name="fr_name3" /></div>
<div class="col-md-3"><input id="fr_lname3" class="form-control" type="text" name="fr_lname3" /></div>
<div class="col-md-6"><input id="fr_email3" class="form-control" type="email" name="fr_email3" /></div>
</div>
</div>
<div class="row">
<div class="col-md-12" style="padding-top: 20px;"><center><input class="submit-btn" type="submit" value="submit" />**</form>**</center></div>
</div>
</div>
the idea is that the form sends the form values to ../comp/checker.php but when I save the page and hit the submit button it just sits there and doesn't go anywhere, I know that the magento cms editor removes certain things, but it hasn't removed anything from the form, any ideas would be helpful.
Magento for security remove certain things like url. if you want to add url in CMS page then you have to use Magento code {{store url=""}} this code generate store url.
Example:
<form id="competition" action="{{store url='checker.php'}}" method="post" name="competition">
Magento also provide custom variable functionality so you can also use it.
Try this html. I have removed duplicate entry type="submit" and corrected missing div tag.
<div class="row">
<div class="col-md-12">
<form id="competition" action="../comp/checker.php" method="post" name="competition">
<span class="input-title">First Name:</span><input id="fname" class="form-control" type="text" name="fname" /> <br />
<span class="input-title">Last Name:</span> <input id="lname" class="form-control" type="text" name="lname" /><br />
<span class="input-title"> Email address: </span><input id="email" class="form-control" type="email" name="email" />
<input type="submit" class="submit-btn" value="submit" />
</form>
</div>
</div>

Uncaught exception 'PDOException' with message coming

contact.php
<div class="block-content collapse in">
<div class="span12">
<?php
if(isset($_POST['submit'])=='Save changes'){
$row=$conn->prepare("SELECT * FROM contact_page WHERE addressline11=? LIMIT
1");
$row->execute(array($_POST['addressline11']));
$q = $conn->prepare("UPDATE contact_page SET contact_content1=?,
contact_content2=?, addressline11=?, addressline22=?, addressline33=?,
tel_no1=?, website1=?, emailid1=?, WHERE id=?");
$q->execute(array($_POST['contact_content1'], $_POST['contact_content2'],
$_POST['addressline11'], $_POST['addressline22'], $_POST['addressline33'],
$_POST['tel_no1'], $_POST['website1'], $_POST['emailid1'], $_GET['id'] ));
echo '<div style="width:72%;"><p style="margin-top: 18px; margin-
left:20px;"><span style="font-weight:bold;vertical-align: top;padding:
12px;">contact_content1:-</span> '.$_POST['contact_content1'].'
<p style="margin-top: 18px; margin-left:20px;"><span style="font-
weight:bold;vertical-align: top;padding: 12px;">contact_content2:-</span>
'.$_POST['contact_content2'].'
<p style="margin-top: 18px; margin-left:20px;"><span style="font-\
weight:bold;vertical-align: top;padding: 12px;">Address Line 11:-</span>
'.$_POST['addressline11'].'
<p style="margin-top: 18px; margin-left:20px;"><span style="font-
weight:bold;vertical-align: top;padding: 12px;">Address Line 22:-</span>
'.$_POST['addressline22'].'
<p style="margin-top: 18px; margin-left:20px;"><span style="font-
weight:bold;vertical-align: top;padding: 12px;">Address Line 33:-</span>
'.$_POST['addressline33'].'
<p style="margin-top: 18px; margin-left:20px;"><span style="font-
weight:bold;vertical-align: top;padding: 12px;">Telephone1 :-</span>
'.$_POST['tel_no1'].'
<p style="margin-top: 18px; margin-left:20px;"><span style="font-
weight:bold;vertical-align: top;padding: 12px;">Website1:-</span>
'.$_POST['website1'].'
<p style="margin-top: 18px; margin-left:20px;"> <span style="font-
weight:bold;vertical-align: top;padding: 12px;">Email Id1:-</span>
'.$_POST['emailid1'];
echo '<p align="left" style="margin-top:10px; padding-left: 20px;
color:blue; text-decoration:none; width:50%; font-weight:bold;"><a
style="color:blue;" href="section2_list.php">Edit More Section 2</a></p>
</div>';
exit;
}
if(!empty($_GET['id'])){
foreach($conn->query("SELECT * FROM contact_page WHERE id='$_GET[id]' LIMIT
1") as $stmt){
echo '<div>
<p>
<form class="form-horizontal" action="" autocomplete="off" method="post"
id="footerform" enctype="multipart/form-data">
<fieldset>
<legend>Footer Section</legend>
<div class="control-group">
<label class="control-label"
for="contact_content1">Contact Content 1</label>
<div class="controls">
<input class="input-xlarge
focused" id="contact_content1" name="contact_content1" type="text" required
value="'.$stmt['contact_content1'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="contact_content2">Contact Content 2</label>
<div class="controls">
<input class="input-xlarge
focused" id="contact_content2" name="contact_content2" type="text" required
value="'.$stmt['contact_content2'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="addressline1">Address line 1</label>
<div class="controls">
<input class="input-xlarge
focused" id="addressline1" name="addressline1" type="text" required
value="'.$stmt['addressline11'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="addressline2">Address line 2</label>
<div class="controls">
<input class="input-xlarge
focused" id="addressline2" name="addressline2" type="text" required
value="'.$stmt['addressline22'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="addressline3">Address line 3</label>
<div class="controls">
<input class="input-xlarge
focused" id="addressline3" name="addressline3" type="text" required
value="'.$stmt['addressline33'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="tel_no">Tel No.</label>
<div class="controls">
<input class="input-xlarge
focused" id="tel_no" name="tel_no" type="text" required
value="'.$stmt['tel_no1'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="website">Website</label>
<div class="controls">
<input class="input-xlarge
focused" id="website" name="website" type="text" required
value="'.$stmt['website1'].'">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="emailid">Email</label>
<div class="controls">
<input class="input-xlarge
focused" id="emailid" name="emailid" type="text" required
value="'.$stmt['emailid1'].'">
</div>
</div>
<div class="form-actions">
<input type="submit" name="submit"
id="submit" class="btn btn-primary" value="Save changes"
onclick="showoutput()">
</div>
</fieldset>
</form>';
}
}
?>
</div>
</div>
</div>
<!-- /block -->
i m editing my form but the error is coming .
Uncaught exception 'PDOException' with message 'SQLSTATE[42000]:
Syntax error or access violation: 1064 You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near'WHERE id='2'' at line 1' in
G:\PleskVhosts\angelsoftweb.com\angelunitrax.com\admin\edit_contact_details.php:175
Stack trace:
#0 G:\PleskVhosts\angelsoftweb.com\angelunitrax.com\admin\edit_contact_details.php(175):
PDOStatement->execute(Array)
#1 {main} thrown in G:\PleskVhosts\angelsoftweb.com\angelunitrax.com\admin\edit_contact_details.php
on line 175
You have an extra comma in the set clause:
emailid1=?, WHERE id=?
Proper query:
UPDATE contact_page SET contact_content1=?,
contact_content2=?, addressline11=?, addressline22=?, addressline33=?,
tel_no1=?, website1=?, emailid1=? WHERE id=?

Categories