Welcome Guest, Not a member yet? Register   Sign In
Newbie in need - can't even follow a drunken tutorial!
#1

[eluser]LukeZach[/eluser]
Hi Guys,

I'm sure I am being an idiot, but I guess that is what being a newbie is all about.

Was trying to follow Michael Wales's tutorial on putting in a 'Contact Us' form to my first CI website ... and my first intro to php.

in the controller i have :

--- contact.php start ---

<?php

function Contact()
{
parent::Controller();
}


class Contact extends Controller{

function index(){

$this->load->helper('form');


$this->load->view('headerview.php');
$this->load->view('contactview.php');
$this->load->view('footerview.php');


$this->load->library('validation');
$rules['name'] = "required|trim";
$rules['email'] = "required|valid_email|trim";
$rules['iamoption'] = "required";
$rules['body'] = "required|trim";
$this->validation->set_rules($rules);

$fields['name'] = 'name';
$fields['email'] = 'email address';
$fields['iamoption'] = 'i am option';
$fields['msgbody'] = 'message body';

$this->validation->set_fields($fields);

if ($this->validation->run())
{
$this->load->view('success');
}
else
{
$this->load->view('contactview');
}




}
}

?>

--- contact.php controller end ----


and in the viewer file I have :

---- contactview.php start ----



<div id="content">

<div id="contact_main">

&lt;?= if ($this->validation->error_string)
{
echo $this->validation->error_string;
} ?&gt;


&lt;?= form_open('contact'); ?&gt;


<p>
<label for="Name">Name:</label><br />
&lt;input type="text" name="Name" class="contactformfield" id="namefield" /&gt;
</p>
<p>
<label for="emailaddress">Email Address:</label> <br />
&lt;input name="emailaddress" type="text" class="contactformfield" id="emailaddress" /&gt;
</p>
<p>
<label for="iamoption">Regarding:</label> <br />
<select name="iamoption" id="iamoption" class="contactformfield">
<option>New Business</option>
<option>Existing Business</option>
<option>University</option>
<option>School</option>
<option>Investor</option>
<option>Press</option>
<option>Other</option>
</select>
</p>

<p>
<label for="msgbody">Email Address:</label> <br />
&lt;textarea name="msgbody" cols="10" rows="5" class="contactformfield" id="msgbody"&gt;&lt;/textarea&gt;
</p>

&lt;input type="submit" value="Send Mail" /&gt;

&lt;?= form_close(); ?&gt;



</div>


--- conactview.php end ----


I am getting this thrown up :


Parse error: syntax error, unexpected T_IF in /Applications/xampp/xamppfiles/htdocs/lza/system/application/views/contactview.php on line 7

line7 : &lt;?= if ($this->validation->error_string)

followed by:

{
echo $this->validation->error_string;
} ?&gt;


Anyone that can end my frustration (it's been well over two hours!) ... THANKS!

Cheers,

Luke


line 7


Messages In This Thread
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 05:34 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 05:54 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 05:59 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 06:01 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 06:02 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 08:28 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 10:00 AM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 12:11 PM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 12:46 PM
Newbie in need - can't even follow a drunken tutorial! - by El Forum - 05-05-2008, 12:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB