Please paste the same code in a new and empty template, save it and let me
know if it saves correctly.
Mugur
On Mon, Jan 25, 2010 at 5:22 PM, Alaa Anabtawi wrote:
> hi guys
>
> am tring to write sql insert quiers inside php tags in campsite templats
> with no sucsess
>
> am redirected to home page when saving the template
>
> here are my code
>
> all are ok and the template can be saved only when removing the quiry line
> between dashes below
>
> any hints please
>
> {{php}}
> $MySQL_DataBase="ospalc_subs";
> $MySQL_Host="localhost";
> $MySQL_User="ospalc_grand";
> $MySQL_Password="qaz123";
> $my_email="info@grandpharm.ps";
> $name1 = $_REQUEST["name0"];
> $name2 = $_REQUEST["name1"];
> $link = mysql_connect($MySQL_Host,$MySQL_User,$MySQL_Password)
> or die("Could not connect : " . mysql_error());
> mysql_select_db($MySQL_DataBase,$link) or die("Could not select database");
>
> ----------------------$strSQL="select * from
> subs";---------------------------------
>
> mysql_query($strSQL,$link) or die("Insert Query failed : " .
> mysql_error());
> mail("$my_email","new person has been registerd","$name1","$name11");
>
> {{/php}}
>
>
> thanks in advance
>
> best regards
>
> --
> Alaa Anabtawi
>
it works only when saving the file as php outside the campsite directory
best regards
On Thu, Jan 28, 2010 at 12:59 PM, Mugur Rus wrote:
> Please paste the same code in a new and empty template, save it and let me
> know if it saves correctly.
>
> Mugur
>
>
> On Mon, Jan 25, 2010 at 5:22 PM, Alaa Anabtawi wrote:
>
>> hi guys
>>
>> am tring to write sql insert quiers inside php tags in campsite templats
>> with no sucsess
>>
>> am redirected to home page when saving the template
>>
>> here are my code
>>
>> all are ok and the template can be saved only when removing the quiry
>> line between dashes below
>>
>> any hints please
>>
>> {{php}}
>> $MySQL_DataBase="ospalc_subs";
>> $MySQL_Host="localhost";
>> $MySQL_User="ospalc_grand";
>> $MySQL_Password="qaz123";
>> $my_email="info@grandpharm.ps";
>> $name1 = $_REQUEST["name0"];
>> $name2 = $_REQUEST["name1"];
>> $link = mysql_connect($MySQL_Host,$MySQL_User,$MySQL_Password)
>> or die("Could not connect : " . mysql_error());
>> mysql_select_db($MySQL_DataBase,$link) or die("Could not select
>> database");
>>
>> ----------------------$strSQL="select * from
>> subs";---------------------------------
>>
>> mysql_query($strSQL,$link) or die("Insert Query failed : " .
>> mysql_error());
>> mail("$my_email","new person has been registerd","$name1","$name11");
>>
>> {{/php}}
>>
>>
>> thanks in advance
>>
>> best regards
>>
>> --
>> Alaa Anabtawi
>>
>
>
I just pasted your php code in a template without any problem. Test
was done in a fresh Campsite 3.3.3 installation.
Anyway, putting code like that including database connection
parameters inside a template is not recommended as any user with
permission to edit templates will see that critical info.
Best thing to do would be to create a smarty template function to do
the task. Another solution is putting your php code in a separate php
file and use {{ include_php }} function to include it, like this:
On Thu, Jan 28, 2010 at 6:17 AM, Alaa Anabtawi wrote:
> i tried doing this with no sucsess
>
> it works only when saving the file as php outside the campsite directory
>
> best regards
>
> On Thu, Jan 28, 2010 at 12:59 PM, Mugur Rus wrote:
>>
>> Please paste the same code in a new and empty template, save it and let me
>> know if it saves correctly.
>>
>> Mugur
>>
>> On Mon, Jan 25, 2010 at 5:22 PM, Alaa Anabtawi wrote:
>>>
>>> hi guys
>>>
>>> am tring to write sql insert quiers inside php tags in campsite templats
>>> with no sucsess
>>>
>>> am redirected to home page when saving the template
>>>
>>> here are my code
>>>
>>> all are ok and the template can be saved