So...first off title says it all. No validation as of yet but cannot seem to get messages to display when sql condition is met seen on lines 9 and 17. Wasn't really sure whether to post in php or sql...
[syntax=php]<?php
session_start();
if (isset($_REQUEST['email'])) {
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("123", $subject, $message, "From:" . $email); echo "Testing successful";
}
else if($_SESSION[adform_access]=="0") {
echo "<form method='post' action='' name='Form1'>
From: <input name='email' type='text' /><br /> <input type='hidden' name='subject' value='$_SERVER[REMOTE_ADDR]' /><br />
<p>Message:</p> <textarea name='message' rows='15' cols='40'></textarea>
<p> </p>
<input type='submit' />
</form>";
}
else if($_SESSION[adform_access]=="1") {
echo "Testing Restricted";
}
else {
echo "Testing error";
}
?>[/syntax]
It seems to always display the form even when the session variable is changed.
sql is simple adform_access 0 = success 1 = restricted any other is an error. Any help would be greatly appreciated
Basic Email Form Thingy
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Basic Email Form Thingy
Last edited by ExtremeGaming on Mon Jul 23, 2012 6:59 am, edited 1 time in total.
Re: Basic Email Form Thingy
I think
[syntax=php]value='$_SERVER[REMOTE_ADDR]'[/syntax]
Has to be
[syntax=php]value=".$_SERVER[REMOTE_ADDR]."[/syntax]
[syntax=php]value='$_SERVER[REMOTE_ADDR]'[/syntax]
Has to be
[syntax=php]value=".$_SERVER[REMOTE_ADDR]."[/syntax]
Re: Basic Email Form Thingy
abcedea wrote:Has to be
[syntax=php]value=".$_SERVER[REMOTE_ADDR]."[/syntax]
nope. single quotes is the correct syntax. I would however use curly brackets. Like this:
[syntax=php]value='{$_SERVER[REMOTE_ADDR]}'[/syntax]
This line is missing some single quotes.
[syntax=php]else if($_SESSION[adform_access]=="1") {[/syntax]
[syntax=php]else if($_SESSION['adform_access']=="1") {[/syntax]
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: Basic Email Form Thingy
Solved did wrong format for sql
Ty for the other help as well totally looked over that
Ty for the other help as well totally looked over that
<?php while(!$succeed = try()); ?>
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: Basic Email Form Thingy
ok one more problem. Since then I added an option to add a on/off/maintenance option to the form. The sql is updating right but if you are to echo the variable it is always set to on? Never seen this happen here is the new code. If you are to execute the code it says there is an error with the form The Access is set on Maintenance
[syntax=php]
<?php
require ('Advertise/Home/Form.php');
if (isset($_REQUEST['email']))
{
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("123", $subject,
$message, "From:" . $email);
echo "Thank you for your service. The requirements for advertising your website will be emailed to "$email" when your email is read and processed. Please <a href='/'>click here</a> to continue.";
}
else if($result == "On")
{
echo "<form method='post' action='' onsubmit='return Form1_Validator(this)' name='Form1'>
From: <input name='email' type='text' readonly='readonly' value='$_SESSION[email]' length='10' /><br />
<input type='hidden' name='subject' value='Home Page Advertisement' type='text'/><br />
<p>Message:</p>
<textarea name='message' rows='15' cols='40'></textarea><br />
<p>*Note: Inappropriate/ Off topic messages will result in a ban.</p>
<p> </p>
<input type='submit' />
</form></font>";
}
else if($result == "Off") {
echo "The advertise form has been taken down temporarily.";
}
else if($result == "Maintenance") {
echo "The advertise form is currently under maintenance. Please check back later.";
}
else {
echo "There is an error with the advertise form. Please contact support.";
}
?>[/syntax]
And Form.php
[syntax=php]
<?php
require ('config.php');
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
$query = "SELECT Access FROM $advertise_table_name WHERE id = '1'";
$result = mysql_query($query);
?>[/syntax]
[syntax=php]
<?php
require ('Advertise/Home/Form.php');
if (isset($_REQUEST['email']))
{
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("123", $subject,
$message, "From:" . $email);
echo "Thank you for your service. The requirements for advertising your website will be emailed to "$email" when your email is read and processed. Please <a href='/'>click here</a> to continue.";
}
else if($result == "On")
{
echo "<form method='post' action='' onsubmit='return Form1_Validator(this)' name='Form1'>
From: <input name='email' type='text' readonly='readonly' value='$_SESSION[email]' length='10' /><br />
<input type='hidden' name='subject' value='Home Page Advertisement' type='text'/><br />
<p>Message:</p>
<textarea name='message' rows='15' cols='40'></textarea><br />
<p>*Note: Inappropriate/ Off topic messages will result in a ban.</p>
<p> </p>
<input type='submit' />
</form></font>";
}
else if($result == "Off") {
echo "The advertise form has been taken down temporarily.";
}
else if($result == "Maintenance") {
echo "The advertise form is currently under maintenance. Please check back later.";
}
else {
echo "There is an error with the advertise form. Please contact support.";
}
?>[/syntax]
And Form.php
[syntax=php]
<?php
require ('config.php');
$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());
$query = "SELECT Access FROM $advertise_table_name WHERE id = '1'";
$result = mysql_query($query);
?>[/syntax]
<?php while(!$succeed = try()); ?>
Re: Basic Email Form Thingy
mysql_query() just performs the query, it does not fetch the result you need to use either mysql_fetch_assoc() or mysql_result(). something like this
[syntax=php]$result = mysql_query($query);
$mode = mysql_result($result);[/syntax]
You could then do your checks on $mode;
[syntax=php]$result = mysql_query($query);
$mode = mysql_result($result);[/syntax]
You could then do your checks on $mode;
-
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: Basic Email Form Thingy
Thank you so much jacek sorry very new to php. Did get an error saying it expects 2 parameters but fixed it by doing [syntax=php]$mode = mysql_result($result, 0);[/syntax] that ok?
<?php while(!$succeed = try()); ?>