Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/126360-drop-down-list-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-653491
Share on other sites

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 :)

Link to comment
https://forums.phpfreaks.com/topic/126360-drop-down-list-help/#findComment-654081
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.