<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Форум PHP-MyAdmin.RU &mdash; Добавление данных в БД через форму]]></title>
		<link>https://forum.php-myadmin.ru/viewtopic.php?id=3308</link>
		<atom:link href="https://forum.php-myadmin.ru/extern.php?action=feed&amp;tid=3308&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Добавление данных в БД через форму».]]></description>
		<lastBuildDate>Tue, 20 May 2014 13:04:02 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24789#p24789</link>
			<description><![CDATA[<div class="quotebox"><cite>Hatiman сказал:</cite><blockquote><p>тока Я не понял что с этим делать foreach($_POST as $ArrKey =&gt; $ArrStr)?</p></blockquote></div><p>Этот цикл можно удалить. Он не работает.</p>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Tue, 20 May 2014 13:04:02 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24789#p24789</guid>
		</item>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24788#p24788</link>
			<description><![CDATA[<div class="quotebox"><cite>Hanut сказал:</cite><blockquote><p>Лучше так тогда, иначе кавычка в переменной сломает запрос:<br />$name = mysql_real_escape_string($_POST[&#039;name&#039;]);</p></blockquote></div><p>Спасибо за помощь. все работает. тока Я не понял что с этим делать foreach($_POST as $ArrKey =&gt; $ArrStr)?</p>]]></description>
			<author><![CDATA[null@example.com (Hatiman)]]></author>
			<pubDate>Tue, 20 May 2014 12:17:17 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24788#p24788</guid>
		</item>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24787#p24787</link>
			<description><![CDATA[<p>Лучше так тогда, иначе кавычка в переменной сломает запрос:<br />$name = mysql_real_escape_string($_POST[&#039;name&#039;]);</p>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Tue, 20 May 2014 09:28:29 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24787#p24787</guid>
		</item>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24786#p24786</link>
			<description><![CDATA[<p>Я сделал, так и все заработало <img src="https://forum.php-myadmin.ru/img/smilies/smile.png" width="15" height="15" alt="smile" /> </p><p>&lt;?<br />}<br />if($_SESSION[&#039;cart&#039;] &amp;&amp; isset($_POST[&#039;order&#039;]))<br />{<br />&nbsp; &nbsp; foreach($_POST as $ArrKey =&gt; $ArrStr) <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $ArrKey = $_POST[$ArrKey];<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $date = date(&#039;Y-m-d&#039;);<br />&nbsp; &nbsp; $time = date(&#039;H:i:s&#039;);<br />&nbsp; &nbsp; $name = $_POST[&#039;name&#039;];<br />&nbsp; &nbsp; $s_name = $_POST[&#039;s_name&#039;];<br />&nbsp; &nbsp; $address = $_POST[&#039;address&#039;];<br />&nbsp; &nbsp; $post_index = $_POST[&#039;post_index&#039;];<br />&nbsp; &nbsp; $email = $_POST[&#039;email&#039;];<br />&nbsp; &nbsp; $phone = $_POST[&#039;phone&#039;];<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; foreach($_SESSION[&#039;cart&#039;] as $id =&gt; $quantity):<br />&nbsp; &nbsp; $product = get_product($id);<br />&nbsp; &nbsp; &nbsp; &nbsp; $result = mysql_query(&quot;INSERT INTO `orders`(date,time,product,prod_id,price,qty) VALUES (&#039;$date&#039;,&#039;$time&#039;,&#039;{$product[&#039;title&#039;]}&#039;,&#039;{$product[&#039;id&#039;]}&#039;,&#039;{$product[&#039;price&#039;]}&#039;,&#039;$quantity&#039;)&quot;);<br />&nbsp; &nbsp; $result = mysql_query(&quot;INSERT INTO `pokupatel`(name,s_name,address,post_index,email,phone,id_order) VALUES (&#039;$name&#039;,&#039;$s_name&#039;,&#039;$address&#039;,&#039;$post_index&#039;,&#039;$email&#039;,&#039;$phone&#039;,&#039;{$orders[&#039;id&#039;]}&#039;)&quot;);&nbsp; &nbsp; <br />&nbsp; &nbsp; <br />&nbsp; &nbsp; endforeach;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; echo &quot;&lt;p align=&#039;center&#039; style=&#039;color: #c51d02;&#039;&gt;Ваш заказ успешно принят! Спасибо за покупку!&lt;/p&gt;&quot;;<br />}<br />?&gt;</p>]]></description>
			<author><![CDATA[null@example.com (Hatiman)]]></author>
			<pubDate>Tue, 20 May 2014 07:50:03 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24786#p24786</guid>
		</item>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24785#p24785</link>
			<description><![CDATA[<p>В запросе вместо $name сделайте так:<br /></p><div class="codebox"><pre><code>VALUES (&#039;&quot; . mysql_real_escape_string($_POST[&#039;name&#039;]) . &quot;&#039;,&#039;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Tue, 20 May 2014 07:20:59 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24785#p24785</guid>
		</item>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24784#p24784</link>
			<description><![CDATA[<p>Неподскажите как оформить&quot;вставить&quot; правильно этот запрос? <br />P.s. Мне самому дельного в голову ничего не лезет.</p>]]></description>
			<author><![CDATA[null@example.com (Hatiman)]]></author>
			<pubDate>Tue, 20 May 2014 07:11:57 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24784#p24784</guid>
		</item>
		<item>
			<title><![CDATA[Re: Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24782#p24782</link>
			<description><![CDATA[<p>Ошибка здесь:<br />$ArrKey = $_POST[$ArrKey];<br />Нельзя так в цикле делать. Вставляйте в таблицу экранированные данные из POST. mysql_real_escape_string($_POST[&#039;name&#039;])</p>]]></description>
			<author><![CDATA[null@example.com (Hanut)]]></author>
			<pubDate>Tue, 20 May 2014 05:20:44 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24782#p24782</guid>
		</item>
		<item>
			<title><![CDATA[Добавление данных в БД через форму]]></title>
			<link>https://forum.php-myadmin.ru/viewtopic.php?pid=24780#p24780</link>
			<description><![CDATA[<p>Применил запрос к MySQL в PHP, но столкнулся с тем что в одной и тойже таблице одни поля заполняются а другие нет.<br /> Вот отрывок:Код PHP<br />if($_SESSION[&#039;cart&#039;] &amp;&amp; isset($_POST[&#039;order&#039;]))<br />{<br />&nbsp; &nbsp; foreach($_POST as $ArrKey =&gt; $ArrStr) <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $ArrKey = $_POST[$ArrKey];<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $date = date(&#039;Y-m-d&#039;);<br />&nbsp; &nbsp; $time = date(&#039;H:i:s&#039;);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; foreach($_SESSION[&#039;cart&#039;] as $id =&gt; $quantity):<br />&nbsp; &nbsp; $product = get_product($id);<br />&nbsp; &nbsp; &nbsp; &nbsp; $result = mysql_query(&quot;INSERT INTO orders(name,s_name,address,post_index,email,date,time,product,prod_id,price,qty) VALUES (&#039;$name&#039;,&#039;$s_name&#039;,&#039;$address&#039;,&#039;$post_index&#039;,&#039;$email&#039;,&#039;$date&#039;,&#039;$time&#039;,&#039;{$product[&#039;title&#039;]}&#039;,&#039;{$product[&#039;id&#039;]}&#039;,&#039;{$product[&#039;price&#039;]}&#039;,&#039;$quantity&#039;)&quot;);<br />&nbsp; &nbsp; endforeach;<br />&nbsp; &nbsp; </p><p>}</p><br /><p>name,s_name,address,email,post_index - эти поля не заполняются! С остальными полями нет проблем.</p><p> Код всей страницы:<br />&lt;h2 align=&quot;center&quot;&gt;Оформление заказа&lt;/h2&gt;</p><p>&lt;?<br />if($_SESSION[&#039;cart&#039;] &amp;&amp; !isset($_POST[&#039;order&#039;]))<br />{<br />?&gt;<br />&lt;form action=&quot;index.php?view=order&quot; method=&quot;post&quot; id=&quot;cart-form&quot;&gt;</p><p>&lt;table id=&quot;mycart&quot; align=&quot;center&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Товар&lt;/th&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Цена&lt;/th&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Кол-во&lt;/th&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Всего&lt;/th&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;</p><p>&nbsp; &nbsp; &nbsp; &lt;? foreach($_SESSION[&#039;cart&#039;] as $id =&gt; $quantity):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$product = get_product($id);<br />&nbsp; &nbsp; &nbsp; ?&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td align=&quot;center&quot;&gt;&lt;?=$product[&#039;title&#039;];?&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td align=&quot;center&quot;&gt;$&lt;?=number_format($product[&#039;price&#039;],2);?&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td align=&quot;center&quot;&gt;&lt;?=$quantity;?&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td align=&quot;center&quot;&gt;$&lt;?=number_format($product[&#039;price&#039;] * $quantity ,2);?&gt;&lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &lt;?endforeach;?&gt;<br />&nbsp; &nbsp; &nbsp; <br />&lt;/table&gt;&nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp;&lt;p class=&quot;total&quot; align=&quot;center&quot;&gt;Общая сумма заказа: &lt;span class=&quot;product-price&quot;&gt;&lt;?=number_format($_SESSION[&#039;total_price&#039;],2);?&gt; $&lt;/span&gt;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;&lt;p align=&quot;center&quot; style=&quot;color:&nbsp; #fff;&quot;&gt;<br />&nbsp; &nbsp; &nbsp;Ваше Имя: &lt;br /&gt;<br />&nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; name=&quot;name&quot;/&gt;&lt;br/&gt;<br />&nbsp; &nbsp; &nbsp;Ваша Фамилия: &lt;br /&gt;<br />&nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; name=&quot;s_name&quot;/&gt;&lt;br/&gt;<br />&nbsp; &nbsp; &nbsp;Ваш адрес: &lt;br /&gt;<br />&nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; name=&quot;address&quot;/&gt;&lt;br/&gt;<br />&nbsp; &nbsp; &nbsp;Почтовый индекс: &lt;br /&gt;<br />&nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; name=&quot;post_index&quot;/&gt;&lt;br/&gt;<br />&nbsp; &nbsp; &nbsp;Ваш e-mail: &lt;br /&gt;<br />&nbsp; &nbsp; &nbsp;&lt;input type=&quot;text&quot; name=&quot;email&quot;/&gt;&lt;br/&gt;<br />&nbsp; &nbsp; &nbsp;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;&lt;p align=&quot;center&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;order&quot; value=&quot;Заказать&quot; /&gt;&lt;/p&gt;&nbsp; &nbsp; <br />&lt;/form&gt;</p><p>&lt;?<br />}<br />if($_SESSION[&#039;cart&#039;] &amp;&amp; isset($_POST[&#039;order&#039;]))<br />{<br />&nbsp; &nbsp; foreach($_POST as $ArrKey =&gt; $ArrStr) <br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $ArrKey = $_POST[$ArrKey];<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; $date = date(&#039;Y-m-d&#039;);<br />&nbsp; &nbsp; $time = date(&#039;H:i:s&#039;);<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; foreach($_SESSION[&#039;cart&#039;] as $id =&gt; $quantity):<br />&nbsp; &nbsp; $product = get_product($id);<br />&nbsp; &nbsp; &nbsp; &nbsp; $result = mysql_query(&quot;INSERT INTO orders(name,s_name,address,post_index,email,date,time,product,prod_id,price,qty) VALUES (&#039;$name&#039;,&#039;$s_name&#039;,&#039;$address&#039;,&#039;$post_index&#039;,&#039;$email&#039;,&#039;$date&#039;,&#039;$time&#039;,&#039;{$product[&#039;title&#039;]}&#039;,&#039;{$product[&#039;id&#039;]}&#039;,&#039;{$product[&#039;price&#039;]}&#039;,&#039;$quantity&#039;)&quot;);<br />&nbsp; &nbsp; endforeach;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; echo &quot;&lt;p align=&#039;center&#039; style=&#039;color: #fff;&#039;&gt;Ваш заказ успешно принят! Спасибо за покупку!&lt;/p&gt;&quot;;<br />}<br />?&gt;&nbsp; </p><br /><p>В чем проблема?</p>]]></description>
			<author><![CDATA[null@example.com (Hatiman)]]></author>
			<pubDate>Mon, 19 May 2014 23:41:54 +0000</pubDate>
			<guid>https://forum.php-myadmin.ru/viewtopic.php?pid=24780#p24780</guid>
		</item>
	</channel>
</rss>
