|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Kryllster Smarty Rookie
Joined: 22 Sep 2007 Posts: 25
|
Posted: Sun Dec 16, 2007 12:02 am Post subject: Need some help with this? |
|
|
I have been searching here on the forums and most of the stuff is beyond me. Anyways I can't figure out how to take this code:
Code: | <?php
$uname = $_POST['uname'];
$address = $_POST['addy'];
$error = "Please enter a valid Name and Email address!";
$success = "Thank you $uname your Email has been added to the database!";
// Test to see if there was and entry
if ($uname == $_POST['']){
echo "$error";
}
elseif ($address == $_POST['']){
echo "$error";
}
else {
// set path of database file
$db = $_SERVER['DOCUMENT_ROOT']."/../email.db";
// open database file
$handle = sqlite_open($db) or die("Could not open database");
sqlite_query($handle, "INSERT INTO list (name, address) Values ('$uname', '$address')");
sqlite_close($handle);
// On success display message!
echo "$success";
}
?> |
and instead of having it display on a separate page I want it to display either message back into the template this is coming from?
Thanks
========== Edited here =================
Here is the solution I came up with.
I took the following code and included it in my index file
Code: |
<?php
$uname = $_POST['uname'];
$address = $_POST['addy'];
$postback = $_POST['postback'];
$error = "Please enter a valid Name and Email address!";
$success = "Thank you $uname your Email has been added to the database!";
// Test of form extended
$flag="OK";
if(strlen($postback) < 1){
$flag="NOTOK";
}
// Test to see if there was and entry
elseif ($uname == $_POST['']){
$smarty->assign('error', $error);
}
elseif ($address == $_POST['']){
$smarty->assign('error', $error);
}
else {
// set path of database file
$db = $_SERVER['DOCUMENT_ROOT']."/../Dbfiles/email.db";
// open database file
$handle = sqlite_open($db) or die("Could not open database");
sqlite_query($handle, "INSERT INTO list (name, address) Values ('$uname', '$address')");
sqlite_close($handle);
// On success display message!
$smarty->assign('success', $success);
}
?>
|
I know it's primitive and I need some way to do it better and also validate the input but some of that stuff is way beyond me right now. Took me all nite to do it lol but all the answers came from smarty mostly!
Any suggestions?? I would like to know how to do this better and safer as well as right???
Thanks |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|