النتائج 1 إلى 6 من 6

الموضوع: فصل كود في الـASP

  1. #1
    عضو نشيط
    تاريخ التسجيل
    May 2001
    المشاركات
    66


    تحية طيبة وبعد
    الاخوة الكرام هذا كود ASP عبارة عن دفتر زوار ومشكلتة ان نموذج الدفتر والعرض في نفس الصفحة وارغب في تطويرة الى ان اضع النموذج في صفحة والعرض في صفحة اخرى ....
    نجحت في الفصل بينهم وهذا ليس بالصعب ولكن حينما ادخل اي زائر جديد لا ينتقل الى صفحة العرض يعني انه هناك خطأ , مع اني ربطة الفورم بملف الـ ASP
    لان اطيل عليكم هذا الكود الاصلي
    كود:
    <% @language=VBScript %>
    <% option explicit %>
    <% Response.Buffer = true %>
    
    <%
    const HITS_PER_PAGE = 5
    const IDS_ANONYMOUS     = "Anonymous"
    const IDS_FIELDSMISSING = "Not all required fields were filled out. Entry was not created."
    const IDS_ERRORDELETE   = "Error deleting entry."
    const IDS_MAIL          = "Send e-mail to"
    const IDS_ERROR         = "Error occured."
    
    const MODE_NORMAL = 1		' normal viewing of the guestbook.
    const MODE_ERROR  = 2		' an error occured and is displayed.
    const MODE_INSERT = 4		' inserting of a item into the guestbook.
    const MODE_DELETE = 8		' deleting of an item of the guestbook.
    const MODE_ADMIN  = 16		' administration-mode: allows deletion of articles.
    dim mode
    mode = Request("mode")
    if mode="" then mode = MODE_NORMAL
    mode = CLng(mode)
    
    function min( a, b )
    	if a<b then min=a else min=b
    end function
    
    function max( a, b )
    	if a>b then max=a else max=b
    end function
    
    function fmtDate( in_str )
    	fmtDate = FormatDateTime( in_str, 2 )
    end function
    
    function fmtMl( in_str )
    	if IsNull(in_str) then
    		fmtMl = ""
    		exit function
    	end if 
    
    	dim str
    	if in_str<>"" then
    		str = Replace( in_str, vbCrLf, vbCr )
    		str = Replace( str   , vbLf  , vbCr )
    		str = Replace( str   , vbCr  , "<br>" )
    
    		fmtMl = str
    	else
    		fmtMl = in_str
    	end if
    end function
    
    function fmtText( byval txt )
    	txt = Server.HtmlEncode(txt)
    
    	txt = Replace( txt, Server.HtmlEncode("<u>"), "<u>" )
    	txt = Replace( txt, Server.HtmlEncode("</u>"), "</u>" )
    
    	txt = Replace( txt, Server.HtmlEncode("<i>"), "<i>" )
    	txt = Replace( txt, Server.HtmlEncode("</i>"), "</i>" )
    
    	txt = Replace( txt, Server.HtmlEncode("<b>"), "<b>" )
    	txt = Replace( txt, Server.HtmlEncode("</b>"), "</b>" )
    
    	txt = Replace( txt, Server.HtmlEncode("<em>"), "<em>" )
    	txt = Replace( txt, Server.HtmlEncode("</em>"), "</em>" )
    
    	fmtText = fmtMl(txt)
    end function
    
    
    function myselfUrl( mode_ )
    	if (CLng(mode) and CLng(MODE_ADMIN))<>CLng(0) then 
    		mode_ = CLng(mode_) or CLng(MODE_ADMIN)
    	end if
    
    	myselfUrl = Request.ServerVariables("SCRIPT_NAME") & "?mode=" & mode_
    end function
    
    function normalUrl
    	normalUrl = myselfUrl(MODE_NORMAL)
    end function
    
    function errorUrl( error_text )
    	errorUrl = myselfUrl(MODE_ERROR) & "&error=" & Server.UrlEncode(error_text)
    end function
    
    function insertUrl
    	insertUrl = myselfUrl(MODE_INSERT)
    end function
    
    function deleteUrl( id )
    	deleteUrl = myselfUrl(MODE_DELETE) & "&id=" & Server.UrlEncode(id)
    end function
    
    function naviUrl( page )
    	naviUrl = myselfUrl(MODE_NORMAL) & "&pg=" & page
    end function
    
    
    function openDb()
    	set openDb = Server.CreateObject("ADODB.Connection")
    	openDb.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    		"Persist Security Info=False;" & _
    		"Data Source=" &Server.MapPath("guestbook.mdb")
    end function
    
    function insertEntry( byref conn )
    	dim name
    	dim email
    	dim text
    
    	name  = Request("gb_name")
    	email = Request("gb_email")
    	text  = Request("gb_text")
    
    	if name="" then name = IDS_ANONYMOUS
    	if text="" then
    		insertEntry = false
    		exit function
    	end if
    
    	dim rs
    	set rs = Server.CreateObject("ADODB.Recordset")
    	rs.Open "Guestbook", conn, 2, 3
    
    	rs.AddNew
    	rs("Date")  = Now
    	rs("Name")  = name
    	if email<>"" then rs("EMail") = email else rs("EMail") = null end if
    	rs("Text")  = text
    	rs.Update
    
    	insertEntry = true
    end function
    
    function deleteEntry( byref conn )
    	dim id
    	id = Request("id")
    
    	if id="" then
    		deleteEntry = false
    		exit function
    	end if
    
    	on error resume next
    	conn.Execute "DELETE FROM Guestbook WHERE No=" &id
    
    	if err<>0 then
    		deleteEntry = false
    	else
    		deleteEntry = true
    	end if
    end function
    
    function hasMode( mode_chk )
    	if (CLng(mode) and CLng(mode_chk))<>0 then
    		hasMode = true
    	else
    		hasMode = false
    	end if
    end function
    
    dim conn
    set conn = openDb
    
    if hasMode(MODE_INSERT) then
    	' when a new entry is posted, insert it.
    	if not insertEntry(conn) then
    		Response.Redirect errorUrl(IDS_FIELDSMISSING)
    	else
    		Response.Redirect normalUrl
    	end if
    end if
    
    if hasMode(MODE_DELETE) then
    	' when an entry needs to be delete, do it.
    	if not deleteEntry(conn) then
    		Response.Redirect errorUrl(IDS_ERRORDELETE& " : " &err.Description)
    	else
    		Response.Redirect normalUrl
    	end if
    end if
    
    dim rs
    set rs = conn.Execute("SELECT COUNT(*) FROM Guestbook")
    
    dim sum_cnt
    sum_cnt = rs(0)
    
    dim cur_page
    if Request("pg")="" then
    	cur_page = 0
    else
    	cur_page = Request("pg")
    end if
    
    dim total_pages
    total_pages = CLng(CLng(sum_cnt)/CLng(HITS_PER_PAGE))
    
    if (CLng(CLng(sum_cnt) mod CLng(HITS_PER_PAGE))>0) and _
    	(CLng(sum_cnt)>CLng(HITS_PER_PAGE)) then
    	total_pages = total_pages+1
    end if
    
    if total_pages<=0 then total_pages=1
    
    ' the # of the displayed hits.
    dim hit_display_start, hit_display_end
    
    hit_display_start = 1+cur_page*HITS_PER_PAGE
    hit_display_end   = hit_display_start+min(CLng(sum_cnt),CLng(HITS_PER_PAGE))-1
    if hit_display_end>sum_cnt then hit_display_end=sum_cnt
    
    dim cntdwn_start
    dim cntdwn_end
    
    cntdwn_start = sum_cnt-hit_display_start+1
    cntdwn_end   = sum_cnt-hit_display_end+1
    
    dim can_prev_page, can_next_page, can_prevornext_page
    
    if CLng(cur_page)>0 then
    	can_prev_page=true
    else
    	can_prev_page=false
    end if
    
    if CLng(cur_page)<CLng(total_pages)-1 then
    	can_next_page=true
    else
    	can_next_page=false
    end if
    
    can_prevornext_page = can_prev_page or can_next_page
    
    dim can_first_page, can_last_page
    
    can_first_page = (can_prevornext_page) and (cur_page>0)
    can_last_page  = (can_prevornext_page) and (CLng(cur_page)<(CLng(total_pages)-1))
    
    
    set rs = conn.Execute("SELECT * FROM Guestbook ORDER BY Date DESC")
    
    if not (rs.Bof and rs.Eof) then
    	rs.Move hit_display_start-1
    end if
    
    
    %>
    
    
    
    <% if hasMode(MODE_ERROR) then %>
    	<p><font color="#FF0000"><b><%=IDS_ERROR &" : "& Request("error")%></b></font><p>
    <% end if %>
    
    <p><a href="#insert">Create new entry</a></p>
    
    
    <p><b><%=sum_cnt%></b> Entries found. 
    	Page <b><%=cur_page+1%></b> of <b><%=total_pages%></b>, 
    	entries <b><%=cntdwn_start%></b> to <b><%=cntdwn_end%></b>.</p>
    
    <p> 
    	<% if can_first_page then %><a href="<%=naviUrl(0)            %>">First page</a><br>   <%end if%>
        <% if can_prev_page  then %><a href="<%=naviUrl(cur_page-1)   %>">Previous page</a><br><%end if%>
    	<% if can_next_page  then %><a href="<%=naviUrl(cur_page+1)   %>">Next page</a><br>    <%end if%>
    	<% if can_last_page  then %><a href="<%=naviUrl(total_pages-1)%>">Last page</a><br>    <%end if%></p>
    
    <p>
    	<%
    	' display discrete pages to jump directly to.
    	dim i
    	for i=1 to total_pages
    	%>
    
    		<a href="<%=naviUrl(i-1)%>">Page <%=i%></a>&nbsp
    
    	<%
    	next
    	%>
    </p>
    
    <%
    dim cntdwn
    cntdwn = cntdwn_start
    
    dim cnt
    cnt = 0
    while not rs.Eof and CLng(cnt)<CLng(HITS_PER_PAGE)
    	cnt = cnt + 1
    
    	dim e
    	if not IsNull(rs("EMail")) then e=true else e=false end if
    %>
    
    	<hr size="1" color="#C0C0C0">
    
    	<p><b><%=cntdwn%>.</b>&nbsp;<%if e then%><a title="<%=IDS_MAIL &" "& rs("EMail")%>"
    		href="mailto:<%=rs("EMail")%>"><%end if%><%=rs("Name")%><%if e then%></a><%end if%>, 
    		<%=fmtDate(rs("Date"))%>
    		<%if hasMode(MODE_ADMIN) then%>&nbsp;<a href="<%=deleteUrl(rs("No"))%>">Delete entry</a><%end if%>
    		</p>
    
    	<p><%=fmtText(rs("Text"))%></p>
    	
    <%
    	cntdwn = cntdwn-1
    
    	rs.MoveNext
    wend
    %>
    
    
    <p><br><hr size="1" color="#C0C0C0"><br></p>
    
    
    <p><a name="insert"></a><b>Create new entry</b></p>
    
    <p>Here you can create a new entry to the guestbook.</p>
    
    <p>
    	<form action="<%=insertUrl%>" method="post">
    		Name:<br>
    		<input type="text" name="gb_name" size="40"><br>
    
    		<br>E-Mail:<br>
    		<input type="text" name="gb_email" size="40"><br>
    
    		<br>Text:<br>
    		<textarea rows="10" name="gb_text" cols="40"></textarea><br>
    
    		<br><input type="submit" value="Insert" name="gb_submit"><br>
    		<input type="hidden" name="insert" value="true">
    	</form>
    </p>
    الاخ العزيز Mr.ASP والله مدري اذا كان الكود اكثر من 1000 سطر او اقل شوي










    aspphp غير متواجد حالياً


  2. #2
    عضو نشيط
    تاريخ التسجيل
    May 2001
    المشاركات
    66


    للرفع..............





    aspphp غير متواجد حالياً

  3. #3
    عضو نشيط
    تاريخ التسجيل
    May 2001
    المشاركات
    66


    مرة ثانية للرفع ...





    aspphp غير متواجد حالياً

  4. #4
    عضو نشيط
    تاريخ التسجيل
    Jul 2000
    المشاركات
    77


    الى الحبيب aspphp
    الى ايش تريد تصل ان منا عارف ممكن توضح ...........
    اوكيه وش رايك احدك على منتدى خبره في asp اوكيه بس انجليزي
    ترا هم يعطون ويه اشوفك هناك
    http://forum.snitz.com/forum/forum.a...rum+Related%29





    aljish غير متواجد حالياً

  5. #5
    عضو نشيط
    تاريخ التسجيل
    Apr 2001
    المشاركات
    53


    بعد الضغط على زر التسجيل يمكنك وضع الكود التالي
    كود:
    <%Response.Redirect( "yourpage.asp" )%>






    ASP4DB غير متواجد حالياً

  6. #6
    عضو نشيط
    تاريخ التسجيل
    May 2001
    المشاركات
    66


    [code]
    <%Response.Redirect( "yourpage.asp" )%>
    [/cofe]
    شاشة عرض الزوار yourpage هل تعني ان الـ






    __________________
    ضعيفان يغلبان قوي
    aspphp غير متواجد حالياً





ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض