herghost Posted September 29, 2008 Share Posted September 29, 2008 Hi All, I Wondered if anyone can help me with this. I have a contact form on my website, which I want to edit slightly. The form is a pretty standard PHP form, but is displayed form a .tpl page. The PHP page is a follows: <? $page = "help_contact1"; include "header.php"; if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; } // SET DEFAULTS $result = ""; $is_error = 0; $error_message = ""; $success = 0; // SET DEFAULT EMAIL IF NOT SUBMITTED if(!isset($_POST['contact_email'])) { $contact_email = $user->user_info[user_email]; } else { $contact_email = $_POST['contact_email']; } // SEND HELP MESSAGE if($task == "dosend") { $contact_name = $_POST['contact_name']; $contact_subject = $_POST['contact_subject']; $contact_message = $_POST['contact_message']; // MAKE SURE FIELDS ARE NOT BLANK if(!is_email_address($contact_email)) { $is_error = 1; $error_message = $help_contact[18]; } if(str_replace(" ", "", $contact_message) == "") { $is_error = 1; $error_message = $help_contact[19]; } if(str_replace(" ", "", $contact_name) == "") { $is_error = 1; $error_message = $help_contact[20]; } // SEND MESSAGE TO SUPERADMIN if($is_error == 0) { $recepient_query = $database->database_query("SELECT admin_email, admin_name FROM se_admins ORDER BY admin_id LIMIT 1"); $recepient_info = $database->database_fetch_assoc($recepient_query); // COMPOSE SUBJECT $subject = "$help_contact[1] $contact_subject"; // COMPOSE MESSAGE $message = "$help_contact[2] $recepient_info[admin_name],\n\n$help_contact[3]\n\n$help_contact[4] $contact_email\n$help_contact[5] $contact_name\n$help_contact[6] $contact_subject\n\n$contact_message"; // SEND MAIL send_helpcontact($recepient_info[admin_email], $contact_email, $subject, $message); // SET RESULT $result = 'Thank you, your message will be passed onto the relevant model'; $success = 1; } } // ASSIGN SMARTY VARIABLES AND INCLUDE FOOTER $smarty->assign('result', $result); $smarty->assign('is_error', $is_error); $smarty->assign('success', $success); $smarty->assign('error_message', $error_message); $smarty->assign('contact_name', $contact_name); $smarty->assign('contact_email', $contact_email); $smarty->assign('contact_subject', $contact_subject); $smarty->assign('contact_message', $contact_message); include "footer.php"; ?> and the .tpl page: {include file='header.tpl'} <img src='./images/icons/help48.gif' border='0' class='icon_big'> <div class='page_header'>{$help_contact11}</div> <div>{$help_contact12}</div> <br> {* SHOW SUCCESS MESSAGE *} {if $result != ""} <br> <table cellpadding='0' cellspacing='0'> <tr> <td class='success'><img src='./images/success.gif' border='0' class='icon'>{$result}</td> </tr> </table> {/if} {* SHOW ERROR MESSAGE *} {if $is_error == 1} <br> <table cellpadding='0' cellspacing='0'> <tr> <td class='error'><img src='./images/error.gif' border='0' class='icon'>{$error_message}</td> </tr> </table> {/if} <br> {* SHOW FORM IF NOT ALREADY SUBMITTED *} {if $success == 0} <form action='form.php' method='POST'> <table cellpadding='0' cellspacing='0' class='form'> <tr> <td class='form1'>Your Name</td> <td class='form2'><input type='text' class='text' name='contact_name' maxlength='50' size='30' value='{$contact_name}'></td> </tr> <tr> <td class='form1'>Your Email</td> <td class='form2'><input type='text' class='text' name='contact_email' maxlength='70' size='30' value='{$contact_email}'></td> </tr> <tr> <td class='form1'>Models ID</td> <td class='form2'><input type='text' class='text' name='contact_subject' maxlength='50' size='30' value='{$contact_subject}'></td> </tr> <tr> <td class='form1'>Job Details & Location</td> <td class='form2'><textarea name='contact_message' rows='7' cols='60'>{$contact_message}</textarea></td> </tr> <tr> <td class='form1'> </td> <td class='form2'><input type='submit' class='button' value='Submit'></td> </tr> </table> <input type='hidden' name='task' value='dosend'> </form> {/if} {include file='footer.tpl'} Want I want, instead of when the page is loaded someone typing the models ID, they can select it from a dropdown list. (the modelsid is the subject field) The usernames are stored in a table se_users in a database se2_ with a field name of user_userid I have tried the below code but it gave me a smarty error <select name="user_userid"> <? while($row = mysql_fetch_object($result)){ ?> <option value="<? echo $row->user_userid; ?>"><? echo $row->user_userid; ?></option> <? } ?> </select> Any help would be lovely Thanks Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/ Share on other sites More sharing options...
F1Fan Posted September 29, 2008 Share Posted September 29, 2008 Your $row variable is not an object, it is an array. replace $row->user_userid with $row['user_userid']. Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-653442 Share on other sites More sharing options...
herghost Posted September 30, 2008 Author Share Posted September 30, 2008 Like this? <select name="user_userid"> <? while($row = mysql_fetch_object($result)){ ?> <option value="<? echo $row->user_userid; ?>"><? echo $row['user_userid'] ?></option> <? } ?> </select> It gives me this error: Fatal error: Smarty error: [in help_contact1.tpl line 47]: syntax error: unrecognized tag: ?> C:\wamp\www\include\smarty\Smarty.class.php on line 1095 Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-653491 Share on other sites More sharing options...
F1Fan Posted September 30, 2008 Share Posted September 30, 2008 Yeah, because you're still doing it. <option value="<? echo $row->user_userid; ?>"><? echo $row['user_userid'] ?></option> See it? You have to replace ALL $row->user_userid with $row['user_userid']. Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-653766 Share on other sites More sharing options...
herghost Posted September 30, 2008 Author Share Posted September 30, 2008 Sorry, posted wrong code: <select name="user_userid"> <? while($row = mysql_fetch_object($result)){ ?> <option value="<? echo $row['user_userid']; ?>"><? echo $row['user_userid']; ?></option> <? } ?> </select> getting the error in my other post. Thanks for your help so far Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-654081 Share on other sites More sharing options...
F1Fan Posted September 30, 2008 Share Posted September 30, 2008 Well, it looks like you have a ?> tag misplaced somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-654104 Share on other sites More sharing options...
herghost Posted September 30, 2008 Author Share Posted September 30, 2008 Thanks F1Fan, As far as I can see they all match up There was a quote I remember reading on here a while ago, why wont it do what I want it do to do instead of what I tell it to do! Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-654255 Share on other sites More sharing options...
CroNiX Posted October 1, 2008 Share Posted October 1, 2008 Try changing your short tags "<?" with real php tags "<?php" Never a good idea to use short tags. Possibly your template parser is ignoring the short tags. Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-654364 Share on other sites More sharing options...
DarkWater Posted October 1, 2008 Share Posted October 1, 2008 Smarty doesn't use php tags. It uses {php}, but I wouldn't suggest using those anyway. Use the proper Smarty structures, they're there for a reason. Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-654365 Share on other sites More sharing options...
herghost Posted October 1, 2008 Author Share Posted October 1, 2008 yeah still stuck thanks for all your help guys, guess I am just trying to change something I don;t know enough about. if anyone would be kind enough to post a code that would work then please do, got to be a good way of learning :0 Quote Link to comment https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-655052 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.